gpt4 book ai didi

loops - 使用循环在 Jenkins 中使用构建流插件运行并行构建

转载 作者:行者123 更新时间:2023-12-01 12:46:16 30 4
gpt4 key购买 nike

我正在使用构建流程插件在 Jenkins 中并行运行任务。最初是这样工作的:

parallel (
{ build("jobX", param: params["inputVal1"])
},
{build("jobX", param: params["inputVal2"])
}
)

但是,我现在的需求要求我在某种循环中编写它,因为作业数量是动态的。我想做这样的事情(概念上):

parallel
(
for(int i=1; i<=numOfJobs; i++)
{
build("jobX", param: params["inputVal" + i])
}
)

Jenkins Buildflow plugin: how to make variable numbers of jobs in parallel? 中提供了答案, 但它并不完全符合我的需要。

最佳答案

你需要这样的东西:

parallel((1..numOfJobs).collect { index ->
{ -> build("job${index}", param: params["inputVal" + index]) }
})

关于loops - 使用循环在 Jenkins 中使用构建流插件运行并行构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34025261/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com