Duplicate pipelines on merge request if set rule for commit changes without merge request
Summary
We need filtered jobs for some files changes and we set 3 rules:
- If it merge request with changes
- If it commit without merge request with same changes
- If it commit in master branch for all
But is cause two pipelines - detached and for commit.
Steps to reproduce
This .gitlab-ci.yml config reproduce problem
stages:
- test
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_MERGE_REQUEST_ID == null
rules-test:
stage: test
rules:
- if: $CI_MERGE_REQUEST_IID
changes:
- .gitlab-ci.yml
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_MERGE_REQUEST_IID == null
changes:
- .gitlab-ci.yml
script:
- echo 'Check rules'
Example Project
Quron/duplicate-pipeline-with-rules!1
What is the current bug behavior?
This condition is cause 2 pipelines on merge request
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_MERGE_REQUEST_IID == null
1 - https://gitlab.com/Quron/duplicate-pipeline-with-rules/pipelines/117560934
2 - https://gitlab.com/Quron/duplicate-pipeline-with-rules/pipelines/117560932
What is the expected correct behavior?
If rule check for mr is true, leave only detached pipeline
Output of checks
This bug happens on GitLab.com
Edited by Alexander Miroshnichenko