Missing documentation of rule evaluation order
Problem to solve
The documentation on rules:if
for GitLab CI contains no information how multiple contrary rules are evaluated. It only list conditions when a rule causes a job to be added to the pipeline
rules:if
Use rules:if clauses to specify when to add a job to a pipeline:
If an if statement is true, add the job to the pipeline. If an if statement is true, but it’s combined with when: never, do not add the job to the pipeline. If no if statements are true, do not add the job to the pipeline.
but not what happens if more than one of these rules apply. A few things are possible then (the first one wins, the last one wins, an error occurs). This should be clearly documented.
Further details
Consider
rules:
- if: $A == "1"
when: never
- if: $B == "2"
when: on_success
and A is 1 and B is 2. Will the job be added to the pipeline or not. And what happens with
rules:
- if: $B == "2"
when: on_success
- if: $A == "1"
when: never
I'll start guessing how this works now with trial and error. If I figure it out, I'll be able to build a pipeline and update this issue, otherwise a dev will know how this works.
Proposal
Pipeline development is insanely frustrating because there's no testing, everything has to be merged and tested with the actual pipelines. Anticipate the need for clear and conscious docs.
Add my example with A and B with the answer to the docs.
Who can address the issue
Anyone who knows how it works.
Other links/references
./.