Rules do not sufficiently replace only/except
Rules are planned to be deprecated in Gitlab 13.0, but there is functionality missing from it.
stages:
- a
- b
job_a:
stage: a
only:
- master
when: manual
job_b:
stage: b
Will results in a pipeline that runs job_b and leaves job_a to be run when decided. When converted to rules, the pipeline becomes blocked instead and job_b will not run.
stages:
- a
- b
job_a:
stage: a
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: manual
job_b:
stage: b
I know that allow_failure will not block, but this causes its own problems as they cannot prevent future jobs from running so if you kick off a manual job and its dependent job, the latter does not wait for the former.
Solution
Based on the following comment
The two usages are not the same;
job_a:
stage: a
only:
- master
when: manual
job_a:
stage: a
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: manual
In the first usage, job_a is already a manual job. In the second one, we do this a manual job if the rules matches.
This would have been a correct mirror;
job_a:
stage: a
when: manual
rules:
- if: $CI_COMMIT_BRANCH == "master"
Edited by Dov Hershkovitch