diff --git a/CHANGELOG.md b/CHANGELOG.md index 22023e6..23236be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.8] - 2019-04-13 +### Added +- Support Cron job name in When clause, by [@bradrydzewski](https://github.com/bradrydzewski). + ## [1.0.7] - 2019-04-10 ### Added - Optionally set the Docker container User, by [@bradrydzewski](https://github.com/bradrydzewski). diff --git a/yaml/compiler/skip.go b/yaml/compiler/skip.go index 4c217b1..a414f55 100644 --- a/yaml/compiler/skip.go +++ b/yaml/compiler/skip.go @@ -20,6 +20,7 @@ import "github.com/drone/drone-yaml/yaml" // pipeline step should be skipped. type SkipData struct { Branch string + Cron string Event string Instance string Ref string @@ -34,6 +35,8 @@ func SkipFunc(data SkipData) func(*yaml.Container) bool { switch { case !container.When.Branch.Match(data.Branch): return true + case !container.When.Cron.Match(data.Cron): + return true case !container.When.Event.Match(data.Event): return true case !container.When.Instance.Match(data.Instance): diff --git a/yaml/compiler/skip_test.go b/yaml/compiler/skip_test.go index f9de2cd..4b98843 100644 --- a/yaml/compiler/skip_test.go +++ b/yaml/compiler/skip_test.go @@ -30,6 +30,19 @@ func TestSkipFunc(t *testing.T) { want: true, }, // + // test cron conditions + // + { + data: SkipData{Cron: "nightly"}, + when: yaml.Conditions{Cron: yaml.Condition{Include: []string{"nightly"}}}, + want: false, + }, + { + data: SkipData{Cron: "nightly"}, + when: yaml.Conditions{Cron: yaml.Condition{Exclude: []string{"nightly"}}}, + want: true, + }, + // // test event conditions // {