英文:
Gitab CI : rules with changes to a dir/path
问题
- 不要添加作业到流水线,当
merge_request_events
触发或者合并请求目标分支受保护且对e2e
目录中的任何文件进行更改时。 - 添加作业当我要合并到的分支是以下之一:
dev
、test
或demo
。 - 在其他情况下不要添加作业到流水线。
这是我的规则:
.ci-rules:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED == "true"'
changes:
- "e2e/**/*"
when: never
- if: '$CI_COMMIT_REF_NAME == "dev" || $CI_COMMIT_REF_NAME == "test" || $CI_COMMIT_REF_NAME == "demo"'
when: always
- when: never
build:
rules:
- !reference [.ci-rules, rules]
stage: build
script:
- echo "do something"
allow_failure: false
问题:
当我更改e2e
目录中的文件时,作业仍然被添加到流水线中。
英文:
I'm trying to add this logic in my CI :
- don't add job to pipeline on
merge_request_events
or when merge request target branch is protected and when changes are made to any file in thee2e
directory - add job when the branch to which I'm merging to is one of the following
dev
,test
ordemo
- don't add job to pipeline in any other case.
Here are my rules
.ci-rules:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED == "true"'
changes:
- "e2e/**/*"
when: never
- if: '$CI_COMMIT_REF_NAME == "dev" || $CI_COMMIT_REF_NAME == "test" || $CI_COMMIT_REF_NAME == "demo"'
when: always
- when: never
build:
rules:
- !reference [.ci-rules, rules]
stage: build
script:
- echo "do something"
allow_failure: false
Issue:
When I make changes to files in e2e
directory only the job is still added to the pipeline.
I'd appreciate any help
答案1
得分: 0
这是我使用以下代码解决的:
.ci-rules:
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" || $CI_COMMIT_REF_NAME == "test" || $CI_COMMIT_REF_NAME == "demo"'
changes:
- "e2e/**/*"
when: never
- if: '$CI_COMMIT_REF_NAME == "dev" || $CI_COMMIT_REF_NAME == "test" || $CI_COMMIT_REF_NAME == "demo"'
when: always
- when: never
英文:
I solved this with the following
.ci-rules:
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" || $CI_COMMIT_REF_NAME == "test" || $CI_COMMIT_REF_NAME == "demo"'
changes:
- "e2e/**/*"
when: never
- if: '$CI_COMMIT_REF_NAME == "dev" || $CI_COMMIT_REF_NAME == "test" || $CI_COMMIT_REF_NAME == "demo"'
when: always
- when: never
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论