Jenkins Buildflow插件:如何并行制作可变数量的工作? [英] Jenkins Buildflow plugin: how to make variable numbers of jobs in parallel?
问题描述
我有一个用BuildFlow制作的作业,该作业接收的参数如job1
,job2
,job1
job2
.
I have a Job made with BuildFlow, this jobs receives a parameter like job1
, job2
, job1
job2
.
在我的DSL中,我用split(",")
分隔了参数的值,所以现在有了一个数组:["job1","job2","job1 job2"]
.
In my DSL I separate the value of the parameter with a split(",")
, so now I have an array with: ["job1","job2","job1 job2"]
.
现在我想让DSL用X构建并行运行一个子作业,其中X是数组的大小,并迭代获取数组的每个位置作为参数传递给子作业的构建. /p>
Now i want to make the DSL run a subjob with X builds in parallel, where X is the size of the array, and iterate to get each position of the array as a paramater to pass to the build of the subjob.
推荐答案
在您的dsl中尝试此操作:
try this within your dsl:
subjob = "yourJobName"
subjobIteration = []
["job1","job2","job1 job2"].each{ parameter ->
//add the closure to trigger the subjob to the list
subjobIteration.add({build( subjob, parameter )})
}
parallel( subjobIteration )
此代码段使用此处记录的并行作业执行语法a>.
This snippet uses the Syntax for Parallel job-executions documented here.
默认情况下,Groovy会正确处理并行" -DSL的列表subjobIteration
,因此不需要进一步的步骤.
Groovy processes the list subjobIteration
by default for the "parallel"-DSL correctly, so no further steps are needed.
这篇关于Jenkins Buildflow插件:如何并行制作可变数量的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!