我有一个工作,当从主分支创建 MR 到开发分支时运行,尽管它不应该根据规则:
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH == "main" && $CI_MERGE_REQUEST_TARGET_BRANCH == "develop"
when: never
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED == "true"
- if: $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_BRANCH !~ /^hotfix\/.*/
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "develop"
changes:
- Admin.Service/**/*
这是我的工作流程:
workflow:
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /phase-.*/
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^bulk\/.*/
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /release-.*/ && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /bugfix.*/
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /release-.*/
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^hotfix\/.*/
- if: $CI_PIPELINE_SOURCE == "trigger"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_BRANCH
根据我的理解,第一条规则应该禁用该作业,并且应相应地忽略以下规则。请帮我弄清楚我做错了什么。如何防止作业进入 MR 管道?
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH == "main" && $CI_MERGE_REQUEST_TARGET_BRANCH == "develop"
when: never
变量名称不正确。应该是
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
和CI_MERGE_REQUEST_TARGET_BRANCH_NAME
。
更正版本:
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "main" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
when: never