mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-29 13:21:10 +00:00
Remove default event filter (#1880)
Closes https://github.com/woodpecker-ci/woodpecker/issues/1863
This commit is contained in:
parent
5c587a3243
commit
eaae6b44c7
4 changed files with 0 additions and 40 deletions
|
@ -303,12 +303,6 @@ when:
|
||||||
|
|
||||||
#### `event`
|
#### `event`
|
||||||
|
|
||||||
:::info
|
|
||||||
**By default steps are filtered by following event types:**
|
|
||||||
|
|
||||||
`push`, `pull_request`, `tag`, `deployment`, `manual`.
|
|
||||||
:::
|
|
||||||
|
|
||||||
Available events: `push`, `pull_request`, `tag`, `deployment`, `cron`, `manual`
|
Available events: `push`, `pull_request`, `tag`, `deployment`, `cron`, `manual`
|
||||||
|
|
||||||
Execute a step if the build event is a `tag`:
|
Execute a step if the build event is a `tag`:
|
||||||
|
|
|
@ -2,11 +2,6 @@
|
||||||
|
|
||||||
To configure cron jobs you need at least push access to the repository.
|
To configure cron jobs you need at least push access to the repository.
|
||||||
|
|
||||||
:::warning
|
|
||||||
By default pipelines triggered by cron jobs wont execute any steps in pipelines, as they are not part of the default event filter and you explicitly need to set a `event: cron` filter.
|
|
||||||
Read more at: [pipeline-syntax#event](./20-pipeline-syntax.md#event)
|
|
||||||
:::
|
|
||||||
|
|
||||||
## Add a new cron job
|
## Add a new cron job
|
||||||
|
|
||||||
1. To create a new cron job adjust your pipeline config(s) and add the event filter to all steps you would like to run by the cron job:
|
1. To create a new cron job adjust your pipeline config(s) and add the event filter to all steps you would like to run by the cron job:
|
||||||
|
|
|
@ -142,8 +142,6 @@ func (when *When) UnmarshalYAML(value *yaml.Node) error {
|
||||||
func (c *Constraint) Match(m metadata.Metadata, global bool) (bool, error) {
|
func (c *Constraint) Match(m metadata.Metadata, global bool) (bool, error) {
|
||||||
match := true
|
match := true
|
||||||
if !global {
|
if !global {
|
||||||
c.SetDefaultEventFilter()
|
|
||||||
|
|
||||||
// apply step only filters
|
// apply step only filters
|
||||||
match = c.Matrix.Match(m.Workflow.Matrix)
|
match = c.Matrix.Match(m.Workflow.Matrix)
|
||||||
}
|
}
|
||||||
|
@ -184,19 +182,6 @@ func (c *Constraint) Match(m metadata.Metadata, global bool) (bool, error) {
|
||||||
return match, nil
|
return match, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultEventFilter set default e event filter if not event filter is already set
|
|
||||||
func (c *Constraint) SetDefaultEventFilter() {
|
|
||||||
if c.Event.IsEmpty() {
|
|
||||||
c.Event.Include = []string{
|
|
||||||
metadata.EventPush,
|
|
||||||
metadata.EventPull,
|
|
||||||
metadata.EventTag,
|
|
||||||
metadata.EventDeploy,
|
|
||||||
metadata.EventManual,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsEmpty return true if a constraint has no conditions
|
// IsEmpty return true if a constraint has no conditions
|
||||||
func (c List) IsEmpty() bool {
|
func (c List) IsEmpty() bool {
|
||||||
return len(c.Include) == 0 && len(c.Exclude) == 0
|
return len(c.Include) == 0 && len(c.Exclude) == 0
|
||||||
|
|
|
@ -477,12 +477,6 @@ func TestConstraints(t *testing.T) {
|
||||||
with: metadata.Metadata{Curr: metadata.Pipeline{Event: metadata.EventPush}, Sys: metadata.System{Host: "beta.agent.tld"}},
|
with: metadata.Metadata{Curr: metadata.Pipeline{Event: metadata.EventPush}, Sys: metadata.System{Host: "beta.agent.tld"}},
|
||||||
want: false,
|
want: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
desc: "filter cron by default constraint",
|
|
||||||
conf: "{}",
|
|
||||||
with: metadata.Metadata{Curr: metadata.Pipeline{Event: metadata.EventCron}},
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
desc: "filter cron by matching name",
|
desc: "filter cron by matching name",
|
||||||
conf: "{ event: cron, cron: job1 }",
|
conf: "{ event: cron, cron: job1 }",
|
||||||
|
@ -495,14 +489,6 @@ func TestConstraints(t *testing.T) {
|
||||||
with: metadata.Metadata{Curr: metadata.Pipeline{Event: metadata.EventCron, Cron: "job1"}},
|
with: metadata.Metadata{Curr: metadata.Pipeline{Event: metadata.EventCron, Cron: "job1"}},
|
||||||
want: false,
|
want: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
desc: "no constraints, event gets filtered by default event filter",
|
|
||||||
conf: "",
|
|
||||||
with: metadata.Metadata{
|
|
||||||
Curr: metadata.Pipeline{Event: "non-default"},
|
|
||||||
},
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
desc: "filter with build-in env passes",
|
desc: "filter with build-in env passes",
|
||||||
conf: "{ branch: ${CI_REPO_DEFAULT_BRANCH} }",
|
conf: "{ branch: ${CI_REPO_DEFAULT_BRANCH} }",
|
||||||
|
|
Loading…
Reference in a new issue