So I have two protected environments stage
and prod
and I’m trying to achieve the following :
- Trigger child pipeline when a merge request is opened and the target branch is protected and
stage
- Trigger child pipeline when MR is merged to a protected branch and the branch name is
stage
- Don’t trigger child pipeline on opened merge requests for a protected environment and the with the name
prod
- Trigger pipeline when MR is merged to a protected environment and the environment name is
prod
build:
stage: build
rules:
- if: $CI_MERGE_REQUEST_ID && ($CI_COMMIT_REF_PROTECTED && $CI_COMMIT_REF_NAME == "stage")
when: always
- if: $CI_MERGE_REQUEST_ID && ($CI_COMMIT_REF_PROTECTED && $CI_COMMIT_REF_NAME == "prod")
when: never
trigger:
include:
- local: myapp/.gitlab-ci.yml
strategy: depend
Unfortunately, these rules don’t trigger the child pipeline for the job it’s specified for when I opened a MR for the stage
protected branch. I’d appreciate any help.