如何防止两个 Jenkins 项目/构建同时运行? [英] How can I prevent two Jenkins projects/builds from running concurrently?

查看:56
本文介绍了如何防止两个 Jenkins 项目/构建同时运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个共享一个数据库的 Jenkins 项目.它们不能同时运行.严格来说,除了非并发之外,它们之间没有特别的依赖关系,但目前我通过运行另一个的下游"来部分地管理这种约束.这在大多数情况下都有效,但并非总是如此.如果在第二个运行时发生源代码控制更改,第一个将再次启动,并且它们将同时运行,并且可能都失败了.

I have two Jenkins projects that share a database. They must not be run simultaneously. Strictly speaking, there is no particular dependency between them beyond non concurrency, but at the moment I partially manage this constraint by running one "downstream" of the other. This works most of the time, but not always. If a source control change happens while the second is running, the first will start up again, and they'll be running concurrently and probably both fail miserably.

这与如何阻止某些 Jenkins 作业同时运行? 不同之处在于我没有线程数"问题——我已经在任何时候最多只运行任何给定项目的一个线程,即使在两个(不同的项目)构建相互踩踏的情况下.这似乎排除了该线程中的所有建议.

This is similar, but not identical, to How to prevent certain Jenkins jobs from running simultaneously? The difference is that I don't have a "number of threads" problem -- I'm already only running at most one thread of any given project at any one time, even in the case where two (different-project) builds stomp each other. This seems to rule out all the several suggestions in that thread.

推荐答案

Locks and Latches plugin 应该可以解决您的问题.创建一个锁并让两个作业使用相同的锁.这将阻止作业并发运行.

The Locks and Latches plugin should resolve your problem. Create a lock and have both jobs use the same lock. That will prevent the jobs from running concurrently.

  1. 在管理 Jenkins:管理插件"中安装插件.
  2. 在管理 Jenkins:配置系统"中定义(提供名称)您的锁.
  3. 对于您想要参与排除的每个工作,
  1. Install the plugin in "Manage Jenkins: Manage Plugins."
  2. Define (provide a name for) your lock(s) in "Manage Jenkins: Configure System."
  3. For each job you want to participate in the exclusion,
  1. 在:配置:构建环境"中,选中锁",
  2. 然后从下拉列表中选择您的锁名称.

这篇关于如何防止两个 Jenkins 项目/构建同时运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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