我有一个存储库,用作语义发布的模板:
release.yml
workflow:
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "test"
when: always
- if: $CI_COMMIT_BRANCH == "main"
when: always
.release:
image: docker-images/semantic-release-test:v0.2.2
variables:
GITLAB_TOKEN: $GITLAB_ACCESS_TOKEN
script:
- npx semantic-release --debug我在另一个项目中引用它
.gitlab-ci.yml
stages:
- release
include:
- project: templates/semantic-release-test
file:
- release.yml
docker_release:
stage: release
extends: .release问题是,在脚本创建新标记之后,仍有第二个管道正在创建。我确实尝试过在没有模板的情况下实现.gitlab-ci.yml中的逻辑,而且它工作得很好。但是,当我使用include密钥时,不管如何,都会触发一个新管道。
我曾尝试过在工作结束时或在.gitlab-ci.yml中添加规则的许多其他变体,比如release.yml,但是没有运气。
对为什么会发生这种事有什么想法吗?
发布于 2022-10-28 06:17:32
我在今天早些时候阅读了您的问题后,在文献资料上看到了以下内容:
使用预定义的CI/CD变量传递关于上游管道的信息。使用插值。将预定义变量保存为触发器作业中的新作业变量,该作业将传递给下游管道。
如果我正确理解的话,在你的情况下应该是这样的:
release.yaml
workflow:
rules:
- if: $PARENT_TAG
when: never
- if: $PARENT_BRANCH == "test"
when: always
- if: $PARENT_BRANCH == "main"
when: always
.release:
image: docker-images/semantic-release-test:v0.2.2
variables:
GITLAB_TOKEN: $GITLAB_ACCESS_TOKEN
script:
- npx semantic-release --debug.gitlab-ci.yml
stages:
- release
include:
- project: templates/semantic-release-test
file:
- release.yml
docker_release:
stage: release
variables:
PARENT_BRANCH: $CI_COMMIT_BRANCH
PARENT_TAG: $CI_COMMIT_TAG
extends: .release编辑:后来的想法
不过,如果只能在父管道中禁用该限制,也可以这样做。
stages:
- release
include:
- project: templates/semantic-release-test
file:
- release.yml
docker_release:
stage: release
extends: .release
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "test"
when: always
- if: $CI_COMMIT_BRANCH == "main"
when: alwayshttps://stackoverflow.com/questions/74228512
复制相似问题