不允许一个 GitLab 项目的 CI 管道同时运行? [英] Disallow CI pipelines of one GitLab project to run concurrently?

查看:10
本文介绍了不允许一个 GitLab 项目的 CI 管道同时运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在内部 GitLab 服务器上,有一个项目的 CI 脚本不允许同时执行多个管道(Kubernetes 中的外部副作用).因此,如果两个提交被连续推送,其间的时间少于第一个管道需要完成的时间,这两个管道将同时运行,这会导致两者都失败.

On an internal GitLab server there is one project with a CI script not tolerating concurrent execution of multiple pipelines (external side effects in Kubernetes). So if two commits are pushed in succession with less time in between than the first pipeline needs to finish, the two pipelines will run concurrently, which causes both to fail.

在这种情况下,为 CI 运行器(跨多个 repos 使用一个 K8s 运行器)全局设置 concurrent = 1 是不切实际的,因为应该允许使用该运行器的其他项目的管道同时运行.

Globally setting concurrent = 1 for the CI runner (one K8s runner used across multiple repos) is not practicable in that case, because pipelines of other projects using that runner should be allowed to run simultaneously.

是否可以仅针对一个项目禁止 CI 并发?取消旧管道或排队新管道都可以.

Is it possible to disallow CI concurrency only for one project? Canceling the older pipeline or queuing up the newer one would both be OK.

推荐答案

您可以使用 limit =1 如下链接所述

You can use limit =1 as discussed in below link

https://gitlab.com/gitlab-org/gitlab-ce/issues/18224

concurrent = 3 // Attribute that limits a number of projects
check_interval = 0
[[runners]]
  limit = 1 // Attribute that limits quantity job by runners
  name = "test-ci"
  url = "https://gitlab.com/ci"
  token = "38274bf1655a0f48d72b15815a83d4e6a85689"
  executor = "shell"
  [runners.cache]

[[runners]]
  limit = 1
  name = "teste2"
  url = "https://gitlab.com/ci"
  token = "38274bf1655a0f48d72b15815a83d4e6a85689"
  executor = "shell"
  [runners.cache]

不要使用共享运行器,而是在您的情况下使用项目特定的运行器,这样其他项目不会受到影响

Instead of using a shared runner, use a project specific runner in your case, so other projects are not impacted

这篇关于不允许一个 GitLab 项目的 CI 管道同时运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆