mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-24 11:00:39 +00:00
support cron job name in when clause
This commit is contained in:
parent
68319d032e
commit
ff450c8266
@ -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).
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
//
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user