如何防止两个Jenkins项目/构建同时运行? [英] How can I prevent two Jenkins projects/builds from running concurrently?
问题描述
我有两个共享数据库的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.
推荐答案
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.
- 在管理Jenkins:管理插件"中安装插件.
- 在管理Jenkins:配置系统"中定义(提供名称)您的锁.
- 对于要参与排除的每个工作,
- Install the plugin in "Manage Jenkins: Manage Plugins."
- Define (provide a name for) your lock(s) in "Manage Jenkins: Configure System."
- For each job you want to participate in the exclusion,
- 在:配置:构建环境"中,选中锁",
- 然后从下拉列表中选择您的锁名.
这篇关于如何防止两个Jenkins项目/构建同时运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!