How do you express "only run this when..." in a pipeline file, without it turning into a mess?
I need conditional behaviour in a pipeline: run this job only on the main branch, run that one only for tagged releases, skip a slow step when only documentation changed, and run something different for merge requests.
My file has grown a tangle of conditions and I no longer trust it. Some jobs run when I do not expect and I find out by watching.
What is the right mental model for conditions here, and how do people keep it readable?
@runner_rauf · 4d ago
The mental model that fixes most tangles: conditions decide whether a job exists in the pipeline, not what it does at run time. They are evaluated once, when the pipeline is created.
That distinction matters because it separates the two tools people mix:
Mixing them is where the mess comes from. A job that always exists and then decides inside the script whether to do anything shows up as a green job that did nothing, which is why you cannot tell what ran.
Rule of thumb: if the answer is knowable when the pipeline starts, put it in the rules. Then the pipeline graph itself tells you what will happen, and you can read it instead of watching it.
Reply
Report