gitlab - 我可以只安排一个特定的 GitLab CI/CD 作业吗?

标签 gitlab continuous-integration gitlab-ci cicd

目前,我在管道内的 gitlab-ci.yaml 中配置了几个 CI/CD 作业。例如,我在一个分支中配置了构建和部署。其中一项工作是创建备份。

我想每晚只安排备份工作。但是,在 GitLab CI/CD 的 schedule 部分,我只能选择一个分支或一个标签。这将导致触发所有阶段/作业,而我只希望触发备份。

我看到了配置 rulesexcepts 以仅在特定上下文中触发作业的选项。然而,这感觉有点像补丁解决方案。在 Gitlab CI/CD 调度程序中是否有另一种方法可以仅触发单个作业?

最佳答案

I've seen the option to configure rules and excepts to only trigger the jobs in a certain context. That, however, feels a bit like a patch solution. Is there another way to trigger only a single job in the Gitlab CI/CD scheduler?

不,除了使用 rules:only:/except: 来控制在管道被触发时运行哪些作业,别无他法按时间表。

您可以将管道配置拆分为多个文件,然后在 include:

上使用适当的 rules:,从而使其更易于管理
include:
  - local: /do-backup.yml
    rules:
      - if: '$CI_PIPELINE_SOURCE == "schedule"'
  - local: /do-pipeline.yml
    rules:
      - if: '$CI_PIPELINE_SOURCE != "schedule"'

这样您就不必对每个作业都应用相同的规则:,您可以为每个作业定义额外的规则:以减少冲突。

关于gitlab - 我可以只安排一个特定的 GitLab CI/CD 作业吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71832594/

相关文章:

gitlab - Gitlab中失败构建的工件

docker - 从 Docker Compose 文件中的 Gitlab 注册表中提取图像

git - 如何在Gitlab中设置默认分支?

python - 工作队列与持续部署框架

asp.net - tfspreview (visualstudio) 可以发布到私有(private) IIS Web 应用程序服务器吗?

node.js - 无法使用 Puppeteer -- 错误 : Failed to launch chrome

nginx - docker-compose + nginx-proxy + Letsencrypt-nginx-proxy-companion + gitlab-ce = git 克隆上的 SSH 连接失败

bash - Jenkins - 无法运行程序 "docker"

Maven 发布插件中的 git-commit 问题

gitlab - 未显示作业工件