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

前端 未结 4 1193
太阳男子
太阳男子 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:23

    You should use pipeline parallel expression, which will wait for all spawned jobs / subtasks to complete:

    stage('testing') {
        def branches = [:]
    
        for(i = 0; i < params.size(); i += 1) {
            def param = params[i]
    
            branches["Test${i}"] = {
                build job: 'Test', parameters: [string(name: 'Name', value: param)], quietPeriod: 2
            }
        }
        parallel branches
    }
    

    You can find some more examples in pipeline docs at jenkins.io

提交回复
热议问题