从本文档中可以这样进行:
// Creation of the stage_list
def stage_list = ["Windows", "Linux"]
// Creation of a map of stages
def stepsForParallel = stage_list.collectEntries {
["echoing ${it}" : transformIntoStage(it)]
}
// Run the stages in parallel
parallel stepsForParallel
// Creation of the stage
def transformIntoStage(inputString) {
return {
stage (inputString) {
steps {
echo "TEST "+inputString
}
}
}
}
您可以在此处找到有关并行Jenkins声明式管道的更多信息。
:
为什么它一起工作steps
和script
,但没有他们?
根据本文档,我认为parallel
与列表一起使用是旧 方法(在Declarative Pipeline 1.2之前),该方法要求在Declarative Pipeline中使用Scripted Pipeline。
似乎新方法parallel
(来自Declarative Pipeline 1.2)不能与列表一起使用。因此,要执行此操作,必须使用 旧的 Scripted Pipeline方法,因此,您需要封装自己的命令pipeline stage_list
,script
而该命令本身必须由封装steps
。
您可以@L_404_3@找到有关脚本化管道和声明性管道的更多信息。