从本文档中可以这样进行:
// Creation of the stage_listdef stage_list = ["Windows", "Linux"]// Creation of a map of stagesdef stepsForParallel = stage_list.collectEntries { ["echoing ${it}" : transformIntoStage(it)]}// Run the stages in parallelparallel stepsForParallel// Creation of the stagedef 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方法,因此,您需要封装自己的命令
pipelinestage_list,
script而该命令本身必须由封装
steps。
您可以在此处找到有关脚本化管道和声明性管道的更多信息。



