Remove default event filter (#1880)

Closes https://github.com/woodpecker-ci/woodpecker/issues/1863
This commit is contained in:
qwerty287 2023-06-21 18:12:20 +02:00 committed by GitHub
parent 5c587a3243
commit eaae6b44c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 40 deletions

View file

@ -303,12 +303,6 @@ when:
#### `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`
Execute a step if the build event is a `tag`:

View file

@ -2,11 +2,6 @@
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
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:

View file

@ -142,8 +142,6 @@ func (when *When) UnmarshalYAML(value *yaml.Node) error {
func (c *Constraint) Match(m metadata.Metadata, global bool) (bool, error) {
match := true
if !global {
c.SetDefaultEventFilter()
// apply step only filters
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
}
// 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
func (c List) IsEmpty() bool {
return len(c.Include) == 0 && len(c.Exclude) == 0

View file

@ -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"}},
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",
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"}},
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",
conf: "{ branch: ${CI_REPO_DEFAULT_BRANCH} }",