woodpecker
woodpecker copied to clipboard
Added support for pipeline root.when conditions
Closes #283
As a ci user I would like to set a file/yaml global when condition, to disable pipeline runs. This allows easier to write control for the pipeline events, branches and metadata.
Changes
- [ ] add root when conditions:
- [ ] branch
- [ ] repo
- [ ] event
- [ ] tag
- [ ] platform
- [ ] instance
- [ ] path
- [x] add docs
- [ ] update yaml schema
- [ ] wait for #686
Fixes
- In hook.go, when one of the yaml(s) was filtered by branch the hook would not fire. Changed to if all are filtered hook is not fired.
- changed function name 'branchFiltered' -> 'checkIfFiltered'
Codecov Report
Merging #770 (2695014) into master (7db7e97) will increase coverage by
0.14%
. The diff coverage is100.00%
.
:exclamation: Current head 2695014 differs from pull request most recent head d6d0f9e. Consider uploading reports for the commit d6d0f9e to get more accurate results
@@ Coverage Diff @@
## master #770 +/- ##
==========================================
+ Coverage 49.57% 49.71% +0.14%
==========================================
Files 86 86
Lines 6548 6557 +9
==========================================
+ Hits 3246 3260 +14
+ Misses 3111 3106 -5
Partials 191 191
Impacted Files | Coverage Δ | |
---|---|---|
server/shared/procBuilder.go | 85.13% <100.00%> (+0.51%) |
:arrow_up: |
server/logging/log.go | 54.65% <0.00%> (+5.81%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@6543 From the current changes I don't think this would be breaking.
I'll look at this code diff asap I'm ready to release v0.15.0 :)
I'm thinking of adding support for multiple root when conditions. E.g.
when:
- event:
- pull_request
- release
- branch: master
This would allow both things to be captured, e.g. Either on master, or on pr and release. @anbraten @6543 What do you think?
@LamaAni We thought about such a change as well #686. Would be quite helpful I think. I would suggest we try to merge this change and then change both root-level when and step-level when to be an array or at least to allow to enter an array somehow.
@anbraten We can use a whenArray for now :) And just add it to both without breaking.
As I suggested in the issue I think a redesign of the yaml config is necessary, mostly since it dose not follow yaml guidelines and treats some dicts as lists (with name). Then, in yaml 2.0 we can do a proper fix for this.
@anbraten @6543 Added support for when array. To allow multiple whens. This would be a temp step before cleaning it?
I'll shortly have a look ...
to the "whenArray" ... we could do this similar to how it's done with the "path" config ... first try to pars it as map ... witch should fail if its an array, then parse it as array ... save this as array internally in all cases ...
@6543 I'll give that a go. And see what we get.
@6543 Updated to auto detect array.
ok ... pipeline/schema/schema.json needs an update & we need good documentation :)
ok ... pipeline/schema/schema.json needs an update & we need good documentation :)
Would you mind adding that @6543 I am not sure what the configuration looks like. Also, we should add the validation as an array no?
ok I'll push it to this branch ...
I'm going to split out the two changes ... A: root.when B: multi-when
Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-770.surge.sh
I'm going to split out the two changes ... A: root.when B: multi-when
=> #1087
I think this should do it, but I like to have some more unit tests for pipeline.when filters ... ... so when I do refactor It wont break
conflicts ...