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]
|
## [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
|
## [1.0.7] - 2019-04-10
|
||||||
### Added
|
### Added
|
||||||
- Optionally set the Docker container User, by [@bradrydzewski](https://github.com/bradrydzewski).
|
- 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.
|
// pipeline step should be skipped.
|
||||||
type SkipData struct {
|
type SkipData struct {
|
||||||
Branch string
|
Branch string
|
||||||
|
Cron string
|
||||||
Event string
|
Event string
|
||||||
Instance string
|
Instance string
|
||||||
Ref string
|
Ref string
|
||||||
@ -34,6 +35,8 @@ func SkipFunc(data SkipData) func(*yaml.Container) bool {
|
|||||||
switch {
|
switch {
|
||||||
case !container.When.Branch.Match(data.Branch):
|
case !container.When.Branch.Match(data.Branch):
|
||||||
return true
|
return true
|
||||||
|
case !container.When.Cron.Match(data.Cron):
|
||||||
|
return true
|
||||||
case !container.When.Event.Match(data.Event):
|
case !container.When.Event.Match(data.Event):
|
||||||
return true
|
return true
|
||||||
case !container.When.Instance.Match(data.Instance):
|
case !container.When.Instance.Match(data.Instance):
|
||||||
|
@ -30,6 +30,19 @@ func TestSkipFunc(t *testing.T) {
|
|||||||
want: true,
|
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
|
// test event conditions
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user