不允许一个 GitLab 项目的 CI 管道同时运行?

Tob*_*ann 5 continuous-integration gitlab

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

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

是否可以仅禁止一个项目使用 CI 并发?取消旧的管道或对新的管道进行排队都可以。

Tar*_*ani 2

您可以limit =1按照以下链接中的讨论使用

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]
Run Code Online (Sandbox Code Playgroud)

不要使用共享运行程序,而是在您的案例中使用特定于项目的运行程序,这样其他项目就不会受到影响

  • 正如文档所述,“限制”是针对并发作业,而不是管道。Runner 仍然可以在完成管道 1 之前启动管道 2 作业 1。 https://docs.gitlab.com/runner/configuration/advanced-configuration.html (2认同)