我在jenkins中运行groovy,我想从功能中分割数据。我试图创建一个具有变量名称和值的映射,但它看起来像函数内部的函数搞砸了。我想拉出CurrentBuildNo,ProjectName,Results_Folder(它们对于每个并行运行是不同的)而不重复代码。
autotests = parallel (
{ ignore(ABORTED) {
retry ( 2 ) {
build("AutoTest", CurrentBuildNo: CurrentBuildNo, ProjectName: params["ProjectName"], Results_Folder: Results_Folder)
} } },
{ ignore(ABORTED) {
retry ( 2 ) {
build("AutoTest", CurrentBuildNo: CurrentBuildNo, ProjectName: params["ProjectName"], Results_Folder: Results_Folder)
} } }
)
我想要的逻辑是:
tests = {{CurrentBuildNo: CurrentBuildNo, ...},{CurrentBuildNo: CurrentBuildNo, ...}}
autotests = parallel (
for (i in tests){
ignore(ABORTED) {
retry ( 2 ) {
build("AutoTest", test[i]['CurrentBuildNo'], test[i]['ProjectName']...)
} } }
}
)
答案 0 :(得分:0)
啊,我想你会想要这样的东西:
def tests = [ [ CurrentBuildNo: CurrentBuildNo, ... ],
[ CurrentBuildNo: CurrentBuildNo, ... ] ]
parallel tests.collect { t ->
{
ignore( ABORTED ) {
retry( 2 ) {
build( 'AutoTest', t.CurrentBuildNo, ... )
}
}
}
}