Reputation: 2655
I have the following structure for my gitlab-ci.yml,
Pipeline basically has 3 stages
All of the jobs use only/except
while job3
uses rules:if
,
Using this created a 'merge request pipeline' on our CI which just run the 'first stage' containing only 'job3'
---
image: node:dubnium
stages:
- first
- secondary
- final
job1:
stage: first
script:
- echo "Stage one - Job 1 lint"
except:
- master
- main
tags:
- docker
- linux
allow_failure: false
job2:
stage: first
script:
- echo "Stage one - Job 2 audit"
except:
- master
- main
tags:
- docker
- linux
allow_failure: false
job3:
stage: first
rules:
- if: $SKIP_TEST != "true"
script:
- echo "Stage one - Job 3 script"
tags:
- docker
- linux
allow_failure: false
job4:
stage: second
tags:
- docker
- linux
except:
- master
- main
script:
- echo "Stage one - Job 4 scan"
job5:
stage: final
tags:
- docker
- linux
only:
- tags
script:
- echo "Stage one - Job 5 build"
I have tried doing like
rules:
- if: $SKIP_TEST != "true"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
But the above snippet just results in the job being skipped entirely.
Also when trying the snippet below, this results in job3 being skipped on our pipelines, but creates a 'merge request pipeline' with first stage containing job3 alone
rules:
- if: $SKIP_TEST != "true" && $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
My question is Is there a way to all in all prevent Gitlab from creating a 'merge request pipeline'?
Upvotes: 0
Views: 78
Reputation: 1070
For merge request pipelines deactivation it is possible to use workflow keyword with rules:
workflow:
rules:
- if: $CI_PIPELINE_SOURCE != "merge_request_event"
Upvotes: 0