Reputation: 2923
I realised that gitlab CI does not seem to allow multiple refs
. It will only take the first.
E.g., for the instructions below, the merge_requests
will be ignored, and will trigger whenever the develop branch is updated directly.
face-build:
stage: build
image: docker:19.03.8
services:
- docker:19.03.8-dind
script:
- sh some-scripts.sh
only:
refs:
- /^develop$/
- merge_requests
If I swap the merge_requests
to be before /^develop$/
it will be triggered for all merge requests.
Is there anyway to set both to be valid?
Upvotes: 3
Views: 2795
Reputation: 1154
If you are using GitLab 12.3 or later, try rules:if
clause instead of only
:
face-build:
stage: build
image: docker:19.03.8
services:
- docker:19.03.8-dind
script:
- sh some-scripts.sh
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^develop$/'
when: always
Please check Rules attributes so you can choose the most appropriat value for when
(on_success
, always
, delayed
or never
).
Upvotes: 3