Merge pull request #1637 from bradrydzewski/master

enabled when status change clause
This commit is contained in:
Brad Rydzewski 2016-05-11 22:05:09 -07:00
commit 8d4354bb6f
2 changed files with 20 additions and 0 deletions

View file

@ -133,6 +133,9 @@ func (a *Agent) prep(w *queue.Work) (*yaml.Config, error) {
transform.Clone(conf, w.Repo.Kind) transform.Clone(conf, w.Repo.Kind)
transform.Environ(conf, envs) transform.Environ(conf, envs)
transform.DefaultFilter(conf) transform.DefaultFilter(conf)
if w.BuildLast != nil {
transform.ChangeFilter(conf, w.BuildLast.Status)
}
transform.ImageSecrets(conf, secrets, w.Build.Event) transform.ImageSecrets(conf, secrets, w.Build.Event)
transform.Identifier(conf) transform.Identifier(conf)

View file

@ -5,6 +5,23 @@ import (
"github.com/drone/drone/yaml" "github.com/drone/drone/yaml"
) )
// ChangeFilter is a transform function that alters status constraints set to
// change and replaces with the opposite of the prior status.
func ChangeFilter(conf *yaml.Config, prev string) {
for _, step := range conf.Pipeline {
for i, status := range step.Constraints.Status.Include {
if status != "change" && status != "changed" {
continue
}
if prev == model.StatusFailure {
step.Constraints.Status.Include[i] = model.StatusSuccess
} else {
step.Constraints.Status.Include[i] = model.StatusFailure
}
}
}
}
// DefaultFilter is a transform function that applies default Filters to each // DefaultFilter is a transform function that applies default Filters to each
// step in the Yaml specification file. // step in the Yaml specification file.
func DefaultFilter(conf *yaml.Config) { func DefaultFilter(conf *yaml.Config) {