gpt4 book ai didi

git - 在 GitLab 的 CI/CD 系统中,如果作业在我的 fork 中,我如何阻止它运行,并且只允许它在 merge 到主仓库时运行?

转载 作者:行者123 更新时间:2023-12-05 03:01:15 24 4
gpt4 key购买 nike

我在我的 gitlab-ci.yml 中有一份工作,比如

build and push:
stage: push
only:
- master
script:
- gcloud docker -- push $IMAGE_TAG

想法是它应该只在分支是 master 时运行,但我也只希望它在 repo 是 app/ 而不是 dave/ 时运行/p>

The docs

The repository path can be used to have jobs executed only for the parent repository and not forks:

job:
only:
- branches@gitlab-org/gitlab-ce

但我无法让它工作。如果我们的 gitlab 服务器是 gitlab.myco.io 并且应用程序是 app/my-project-name 我想我可以放

job:
only:
- branches@gitlab-myco-io/app/my-project-name/master

但这似乎不起作用。

正确的做法是什么?

最佳答案

基于 privateomega's answer , 因为 only / except are being deprecated ,具有 rules 的现代替代方案,也支持通用的主分支名称,类似于:

job:
rules:
- if: '$CI_PROJECT_NAMESPACE == "app" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

另见 https://about.gitlab.com/releases/2020/04/22/gitlab-12-10-released/#auto-devops-and-secure-configuration-templates-are-changing-to-%60rules%60-instead-of-%60only/except%60

关于git - 在 GitLab 的 CI/CD 系统中,如果作业在我的 fork 中,我如何阻止它运行,并且只允许它在 merge 到主仓库时运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56070922/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com