Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55600

Parallel execution of same job N times with different parameters leads to only 1 execution of the job


    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • groovy-plugin
    •  Jenkins 2.150.1, Pipeline-Groovy Plugin 2.57

      1) I created sample job (see "sample_job_config.xml" attachment) which has "PROJECT_NAME" parameter
      2) I want to run it in parallel 5 times with different "PROJECT_NAME" values. I created following script for this:

      pipeline {
          agent none
          stages {
              stage('Processing projects') {
                  steps {
                      script {
                          def projects = ['project0', 'project1', 'project2', 'project3', 'project4']
                          def projectsBuilds = [:]
                          def labelParameters
                          for (project in projects) {
                              //JENKINS-55426 need to save iterated variable value into intermediate variable, otherwise there will be last value from collection for all jobs
                              def currentProject = project
                              labelParameters = []
                              labelParameters.add([$class: 'LabelParameterValue', name: 'node', label: 'linux'])
                              labelParameters.add([$class: "StringParameterValue", name: "PROJECT_NAME", value: currentProject])
                              projectsBuilds[currentProject] = {
                                  stage(String.format('%s execution', currentProject)) {
                                      build job: 'Sample-Job', parameters: labelParameters
                          parallel projectsBuilds;

      3) However, when I run this script it only invokes job ONCE, not FIVE TIMES (see screen)

            vjuranek vjuranek
            alpanshin Alexandr Panshin
            0 Vote for this issue
            1 Start watching this issue