'Stop detach pipelines from getting created
I had a gitlab job defined as follows.
test-1:
stage: test
only:
variables:
- $RUN_TEST
except:
- tags
and then I changed that job to run based on gitlab rules.
test-1:
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_TAG == null'
- if: '$RUN_TESTS == "true" && $CI_COMMIT_TAG == null'
After this change, Whenever I commit some change to my branch, I am getting two pipeline runs in my gitlab project. One is for the latest commit I have made and second as detached.
How can I get rid of detached pipeline run?
Another interesting thing is, when I cancel the latest pipeline the detach pipeline also got cancelled.
For latest pipeline, value of CI_PIPELINE_SOURCE = push and for detach pipeline, value of CI_PIPELINE_SOURCE = merge_request_event.
Solution 1:[1]
The detached pipelines you are seeing are merge request pipelines. You can use workflow:rules to control when a pipeline is created. To prevent merge request pipelines:
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- when: always
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sytech |
