In my pipeline, I’d like to have a job run only if the Merge Requests target branch is a certain branch, say release/1.0.0-rc or release/1.5.0-rc, etc.
Here is my job:
build-composer:
stage: build-app
image:
name: $PHP_IMAGE
entrypoint: [""]
script:
- composer install
artifacts:
paths:
- vendor/
expire_in: 1h
rules:
- if: '$CI_COMMIT_BRANCH == "dev" && $CI_COMMIT_TAG == null'
when: always
- if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "dev" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^release/.*$/ && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_STATE == "merged"'
when: always
- if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^feature/.*$/ && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "dev" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_STATE == "merged"'
when: always
the attempt to merge the request from the feature/* branch to dev successfully triggered the pipeline to run after the merge. However, when merging from the dev branch to release/1.0.0-rc, no pipeline is triggered.
I’ve also tried changing =~ /^release/.*$/
to == "release/**"
, but no luck.
Raja Haikal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.