rules:if causes two pipelines to be run on MRs and jobs to be missing
Summary
When using rules:if when
, after force pushing to MR, instead of 1 pipeline, 2 are run, one regular and one detached MR. To make things worse, the detached pipeline is mutilated, jobs that have no rules
defined on them are missing.
This bug breaks MRs' pipelines when rules:
are used.
This makes rules:
rather hard to apply in complex pipelines with dependencies. Imagine there's a deploy job, that can be triggered manually (when: manual
) on every pipeline (think of: deploy to demo lab) and should be triggered on a scheduled nightly pipeline (think of: bring demo lab up to speed) always (when: on_success
). This deploy job depends on a build job, that has to run on every pipeline, a job that does not need rules
.
Instead I'll end up with duplicating jobs and toying with only/except
. Also I guess, spamming with rules:
could also solve this issue.
Steps to reproduce
- Have
.gitlab-ci.yml
withrules
on at least one job and at least one job without it - optionally: to a job with
rules
, add aneeds
/depends
to make it depend on a job withoutrules
- Commit some changes
- Make MR
- Observe pipelines in MR
Example Project
https://gitlab.com/falxcerebri/gitlab-ci-rules-bug/
What is the current bug behavior?
When there's a rules:
block present in .gitlab-ci.yml block, two pipelines are run, one regular, and one detached on top of it. The detached features only jobs with rules
and nothing else, leading to pipeline failing on unmet dependencies.
falxcerebri/gitlab-ci-rules-bug!1
Note that rules:
only change when
from manual
to on_success
, not the actual presence of any job.
Everything is exposed in my sample repo: https://gitlab.com/falxcerebri/gitlab-ci-rules-bug/
What is the expected correct behavior?
- There should be just one pipeline in Merge Request, since there's no
only:/except: merge_request
used anywhere - Even if 2 pipelines are necessary due some technical reasons, the resulting detached pipeline should consist of all jobs, not only these with
rules:
prop
Relevant logs and/or screenshots
falxcerebri/gitlab-ci-rules-bug!2
Output of checks
GitLab.com
Possible fixes
Unfortunately I have no idea. I guess this may be somewhat linked with detached pipeline settings but that's just a wild guess.