How to make Pipeline job to wait for all triggered parallel jobs?

前端 未结 4 1194
太阳男子
太阳男子 2020-12-28 16:48

I\'ve Groovy script as part of the Pipeline job in Jenkins as below:

node {
    stage(\'Testing\') {
        build job: \'Test\', parameters: [string(name: \         


        
4条回答
  •  青春惊慌失措
    2020-12-28 17:37

    However @agg3l's example is not working with multiple jobs.

    Map jobResults = [:]
    
    Boolean failedJobs = false
    def buildJobWithParams(def jobs_list, Map results) {
      def branches = [:]    
      for(job in jobs_list)
      {
        print job
        branches["Test-${job}"] = {
           def jobBuild = build job: job, propagate: false
           def jobResult = jobBuild.getResult()
           echo "Build of '${job}' returned result: ${jobResult}"
           results[job] = jobResult
        }
      }    
      return branches
    }
    
    stage('Run integration tests') {
          steps {
                def job_branch = buildJobWithParams(item_list, jobResults)
                print job_branch
                parallel job_branch
              }
    }
    

    The item_list has more than 1 job, however it will execute only last job multiple times.

提交回复
热议问题