mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
Move skip-ci back in front of config fetching (#2555)
This commit is contained in:
parent
46273e54d8
commit
62d6a6bc34
@ -19,20 +19,16 @@ import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/antonmedv/expr"
|
||||
"github.com/bmatcuk/doublestar/v4"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/metadata"
|
||||
yamlBaseTypes "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
|
||||
)
|
||||
|
||||
var skipRe = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`)
|
||||
|
||||
type (
|
||||
// When defines a set of runtime constraints.
|
||||
When struct {
|
||||
@ -82,16 +78,6 @@ func (when *When) IsEmpty() bool {
|
||||
|
||||
// Returns true if at least one of the internal constraints is true.
|
||||
func (when *When) Match(metadata metadata.Metadata, global bool, env map[string]string) (bool, error) {
|
||||
if global {
|
||||
// skip the whole workflow if any case-insensitive combination of the words "skip" and "ci"
|
||||
// wrapped in square brackets appear in the commit message
|
||||
skipMatch := skipRe.FindString(metadata.Curr.Commit.Message)
|
||||
if len(skipMatch) > 0 {
|
||||
log.Debug().Msgf("skip workflow as keyword to do so was detected in commit message '%s'", metadata.Curr.Commit.Message)
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
for _, c := range when.Constraints {
|
||||
match, err := c.Match(metadata, global, env)
|
||||
if err != nil {
|
||||
|
@ -17,6 +17,7 @@ package pipeline
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
@ -27,6 +28,8 @@ import (
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
)
|
||||
|
||||
var skipPipelineRegex = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`)
|
||||
|
||||
// Create a new pipeline and start it
|
||||
func Create(ctx context.Context, _store store.Store, repo *model.Repo, pipeline *model.Pipeline) (*model.Pipeline, error) {
|
||||
repoUser, err := _store.GetUser(repo.UserID)
|
||||
@ -36,6 +39,12 @@ func Create(ctx context.Context, _store store.Store, repo *model.Repo, pipeline
|
||||
return nil, fmt.Errorf(msg)
|
||||
}
|
||||
|
||||
skipMatch := skipPipelineRegex.FindString(pipeline.Message)
|
||||
if len(skipMatch) > 0 {
|
||||
log.Debug().Str("repo", repo.FullName).Msgf("ignoring pipeline as skip-ci was found in the commit (%s) message '%s'", pipeline.Commit, pipeline.Message)
|
||||
return nil, ErrFiltered
|
||||
}
|
||||
|
||||
// If the forge has a refresh token, the current access token
|
||||
// may be stale. Therefore, we should refresh prior to dispatching
|
||||
// the pipeline.
|
||||
|
Loading…
Reference in New Issue
Block a user