0

I'm trying to generate and launch build stages in parallel for a list of projects in a loop:

steps {
 ...
  PROJECT_LIST = []
  PROJECT_LIST += "project1"
  PROJECT_LIST += "project2"
  PROJECT_LIST += "project3"
   for (def element = 0; element < PROJECT_LIST.size(); element++) {
  //parallel {
    stage("Parallel build run on ${PROJECT_LIST[element]}") {
      build_project "${PROJECT_LIST[element]}"
    }
  }
 //}
 ...
}

I can run it's stages without any problems, but when I uncomment

parallel {}

statement I get java.lang.IllegalArgumentException: Expected named arguments but got org.jenkinsci.plugins.workflow.cps.CpsClosure2@3de759b7 error.

1 Answers1

0

You can use Parallel Stages instead of a loop

Ex:

parallel(
      a: {
        build_project  "project1"
     },
      b: {
        build_project  "project2"
      },
      c: {
        build_project  "project3"
      },

    )

MoreInfo

Rakesh
  • 81,458
  • 17
  • 76
  • 113