continuous-integration - 禁用先前管道的给定手 Action 业

标签 continuous-integration gitlab gitlab-ci gitlab-ci-runner

我在 GitLab CI 管道中进行了这个概念验证(仅显示相关部分):

deploy:development:
  stage: deploy
  rules:
    - if: $CI_COMMIT_BRANCH == "master"
  script: do_deploy
  variables:
    ANSIBLE_INVENTORY: development

deploy:test:
  stage: deploy
  environment:
    name: test
    url: https://env.url.tld
  rules:
    - if: $CI_COMMIT_BRANCH == "master"
      when: manual
  script: do_deploy
  variables:
    ANSIBLE_INVENTORY: test

我想在创建新作业时禁用/弃用之前的 deploy:test 作业。基本上,deploy:test 作业应该只针对当前/最新的管道启用,从而防止旧的构建接管最近的构建。

I'm not saying that it should happens instantaneously; if it's running, is fine to let if finish, but if it failed and a new one is created, the old one (failed) should be disabled also. Same for the current one, if it ran successfully, it should be disabled — this is an optimal state.

是否有配置设置可以让我这样做?我已在设置 > CI/CD > 常规管道中检查了自动取消冗余、挂起的管道跳过过时的部署作业,但仍然是作业不会在以前的管道上被禁用。

最佳答案

I have checked Auto-cancel redundant, pending pipelines and Skip outdated deployment jobs in Settings > CI/CD > General pipelines, but still the job doesn't get disabled on previous pipelines.

它应该与 GitLab 15.5 配合使用效果更好(2022 年 10 月):

Prevent outdated deployment jobs

Previously, some outdated jobs could be manually started or retried even when Skip outdated deployment jobs is enabled.

We have updated the logic for this setting to check the deployment status when a job starts.

The job does not execute if the deployment job is outdated due to a more recent deployment.
This check ensures that outdated deployment jobs are not accidentally started, overwriting more recent code changes in production.

See Documentation and Issue.

关于continuous-integration - 禁用先前管道的给定手 Action 业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62939079/

相关文章:

gitlab - 如何将 gitlab ci 环境变量转储到文件

oauth - GitLab 刷新 oAuth token

meteor - 如何使用 Gitlab CI/CD 部署 meteor 项目?

gitlab - 将 Gitmodules 与 GitLab CI 结合使用不起作用

continuous-integration - 在 Visual Studio Online 上使用持续集成部署 Azure WebJobs

Azure DevOps - 用户作为审批者触发发布

docker - 从 Kubernetes cronjob 中的私有(private)注册表中提取图像失败

GitLab Runner Parallels Executor 和 Windows 10 VM - 卡住 "Creating new VM..."

java - 如何设置新的 Jenkins slave

javascript - npm run build 失败并显示 "Error: custom keyword definition is invalid: data.errors should be boolean"