简体   繁体   English

管理两个不同但相关的 jenkins 作业的构建

[英]Managing builds of two different but related jenkins jobs

I have two jenkins declarative pipeline jobs A and B. Job A needs to have concurrent builds but Job B cannot be run when Job A is running and Job B cannot be run concurrently.我有两个 jenkins 声明性管道作业 A 和 B。作业 A 需要进行并发构建,但当作业 A 正在运行且作业 B 无法同时运行时,作业 B 无法运行。 I dont want to block concurrent build of Job A by locking resource using Lockable Resources plugin.我不想通过使用 Lockable Resources 插件锁定资源来阻止作业 A 的并发构建。 How can I make this scenario work.我怎样才能让这个场景起作用。 Any ideas or suggestions?有什么想法或建议吗?

There isn't a great solution to this.对此没有很好的解决方案。 The "Right" solution IMO is a read/write mutex, where B can lock for R/W (so neither A nor B can use the resource), but A can lock only for W (so A can continue to acquire Read locks, but B cannot acquire its Write lock). “正确”的解决方案 IMO 是读/写互斥锁,其中B可以锁定 R/W(因此 A 和 B 都不能使用资源),但A只能锁定 W(因此A可以继续获取读锁,但B不能获得它的写锁)。

The best workaround I've seen so far is to manually create a large pool of lockable resources with the same label.到目前为止,我见过的最好的解决方法是手动创建大量具有相同标签的可锁定资源池。 Have A request a lock on one resource of that label at a time, while B locks the entire pool (note that the lock step has a parameter quantity ).A请求锁定该标签的一个资源,而B锁定整个池(注意lock步骤有一个参数quantity )。 This allows the same functionality, but is a lot more arcane and doesn't scale as well (if you suddenly need 100 runs of A concurrently but only created 50 resources, you no longer have full parallelism)这允许相同的功能,但更神秘并且不能扩展(如果您突然需要同时运行 100 次A但只创建了 50 个资源,则不再具有完全并行性)

Can you have Job B monitor execution of Job A, so Job B is only triggered after Job A has completed?是否可以让作业 B 监控作业 A 的执行,以便作业 B 仅在作业 A 完成后触发?

在此处输入图片说明

Update.更新。

I understand that part, but by having one job trigger another, he will ensure they don't run concurrently.我理解那部分,但是通过让一项工作触发另一项工作,他将确保它们不会同时运行。 Other solution would be adding a small pipeline to Job B, which checks whether Job A is still running:其他解决方案是向作业 B 添加一个小管道,它检查作业 A 是否仍在运行:

def jenkins = Jenkins.getInstance()
def jobName = "Job A"
def job = jenkins.getItem(jobName)
if(job.isBuilding()) {
    <insert your logic>
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置Jenkins将与构建工作有关的相同数据插入到两个不同的数据库中? - How to Configure Jenkins to insert the same data related to build of the jobs in jenkins to two different databases? 比较两个不同作业的Jenkins配置 - Compare Jenkins Configuration for two different jobs Jenkins(Hudson) - 管理并行构建之间的依赖关系 - Jenkins (Hudson) - Managing dependencies between parallel builds 一个用于两个不同jenkins构建的svn项目(具有另一个依赖项) - one svn project for two different jenkins builds (with another dependency) JENKINS构建运行并行和顺序作业 - JENKINS Builds run parallel and Sequential jobs Jenkins 删除所有作业的最新 20 个版本之前的版本 - Jenkins delete builds older than latest 20 builds for all jobs 使用2个jenkins作业制作jenkins多作业驻留在两个不同的jenkins服务器中 - Making a jenkins multijob using 2 jenkins jobs reside in two different jenkins servers 詹金斯一次与不同的奴隶一起建造 - Jenkins builds with different slaves at a time 詹金斯的工作进展缓慢。 与I / O相关吗? - Jenkins jobs slow. Is it I/O related? 相同的Jenkins配置可用于2个不同的作业 - Same Jenkins Configuration for 2 Different Jobs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM