git - 在 GitLab 的 CI/CD 系统中,如果作业在我的 fork 中,我如何防止它运行,并且只有在它合并到主仓库时才允许它运行?
问题描述
我有一份gitlab-ci.yml
喜欢的工作
build and push:
stage: push
only:
- master
script:
- gcloud docker -- push $IMAGE_TAG
这个想法是它应该只在分支是 master 时运行,但我也只希望它在 repo 是app/
而不是repo 时运行dave/
文档说
存储库路径可用于仅为父存储库而不是 fork 执行作业:
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 的答案,因为only / except 已被弃用,现代替代方案 with rules
,也支持通用主分支名称,将类似于:
job:
rules:
- if: '$CI_PROJECT_NAMESPACE == "app" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
推荐阅读
- autohotkey - AutoHotkey 脚本用不同的配置文件打开 chrome
- python - 条形聊天绘图问题:posx 和 posy 应该是有限值
- extjs - 如何更改 EXTJS 日历中的移动间隔?
- notion-api - 使用 Notion API 在父块的特定位置附加子块
- spring - 未使用 Spring Boot 加载表
- android - 回收者视图中多视图类型的最佳结构是什么
- unity3d - 我可以在游戏发行版中使用实验包吗?
- c++ - 我正在编写一个 cpp 程序来打印两个数字之间的所有素数。程序运行成功,但没有打印任何东西
- angular - 路由组件是否有可能具有输入?
- java - Java 流过滤器取 1 个元素