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

Declarative pipeline multiple stages in parallel when use loop

    Details

    • Similar Issues:

      Description

      https://jenkins.io/blog/2018/07/02/whats-new-declarative-piepline-13x-sequential-stages/

      As the links above, can i use for loops to reuse code.

       

      def jobs = ["JobA", "JobB", "JobC"]
      def parallelStagesMap = jobs.collectEntries {
       ["${it}" : generateStage(it)]
      }
      def generateStage(job) {
          return {
              stage("stage: ${job}") {
                  stages {
                      stage ('complie') {
                          agent xxx
                          steps {
                              echo "${job} complie."
                          }
                      } 
                      stage(‘build') {
                          steps {
                              echo “${job} build."
                          }
                      }
                   } 
               }
           }
       }
      pipeline {
           agent any 
           stages {
               stage(‘xxx') {
                ...
                }
               stage('parallel stage') {
                   steps {
                       script{ 
                           parallel parallelStagesMap 
                       }
                   }
               }
           }
       }
      

       The above pipeline not work with error "No such DSL method ‘xxxx' found among steps "

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              abayer Andrew Bayer
              Reporter:
              jc_sha jack sha
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: