[英]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.