-
Bug
-
Resolution: Not A Defect
-
Minor
-
None
I found parallel do behave differently when using a for loop or an each loop when filling the list.
def sub_jobs = [:] for (platform in selected_platforms) { sub_jobs[platform] = { build job: job_name, parameters: [ string(name: 'Platform', value: platform), string(name: 'Upstream Project Build Number', value: BUILD_NUMBER) ], wait: true } } parallel sub_jobs
results in:
[Pipeline] parallel [Pipeline] { (Branch: WIN10) [Pipeline] { (Branch: U1604) [Pipeline] build (Building Product) 11:36:56 Scheduling project: Product [Pipeline] build (Building Product) 11:36:56 Scheduling project: Product 11:37:01 Starting building: Product #37 11:37:01 Starting building: Product #37
So only one platform is build in this case.
But an each loop works:
def sub_jobs = [:] selected_platforms.each { sub_jobs[it] = { build job: job_name, parameters: [ string(name: 'Platform', value: it), string(name: 'Upstream Project Build Number', value: BUILD_NUMBER) ], wait: true } } parallel sub_jobs
[Pipeline] parallel [Pipeline] { (Branch: WIN10) [Pipeline] { (Branch: U1604) [Pipeline] build (Building Product) 11:36:56 Scheduling project: Product [Pipeline] build (Building Product) 11:36:56 Scheduling project: Product 11:37:01 Starting building: Product #38 11:37:01 Starting building: Product #39
Running on Jenkins 2.222.1 Docker LTS Image