[JIRA] (JENKINS-61778) build job won't trigger if filled in for loop

4 views
Skip to first unread message

nils.gerke@digitalwerk.net (JIRA)

unread,
Apr 2, 2020, 6:22:02 AM4/2/20
to jenkinsc...@googlegroups.com
Nils Gerke created an issue
 
Jenkins / Bug JENKINS-61778
build job won't trigger if filled in for loop
Issue Type: Bug Bug
Assignee: Unassigned
Components: _unsorted
Created: 2020-04-02 10:21
Priority: Minor Minor
Reporter: Nils Gerke

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

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

m_winter@gmx.de (JIRA)

unread,
Apr 11, 2020, 8:02:03 PM4/11/20
to jenkinsc...@googlegroups.com
Markus Winter commented on Bug JENKINS-61778
 
Re: build job won't trigger if filled in for loop

This is not a bug. The following will do the trick:

def sub_jobs = [:]
    for (platform in selected_platforms) {
        def pf = platform
        sub_jobs[pf] = {
            build job:  job_name,
                parameters: [
                    string(name: 'Platform', value: pf),
                    string(name: 'Upstream Project Build Number', value: BUILD_NUMBER)
                ], wait: true
        }
    }
parallel sub_jobs

(See Pipeline Exampels)

 

m_winter@gmx.de (JIRA)

unread,
Apr 11, 2020, 8:05:02 PM4/11/20
to jenkinsc...@googlegroups.com
Markus Winter resolved as Not A Defect
 
Change By: Markus Winter
Status: Open Resolved
Resolution: Not A Defect

nils.gerke@digitalwerk.net (JIRA)

unread,
Apr 15, 2020, 2:10:03 AM4/15/20
to jenkinsc...@googlegroups.com
Nils Gerke commented on Bug JENKINS-61778
 
Re: build job won't trigger if filled in for loop

So platform is mutable in the for loop, good to know

nils.gerke@digitalwerk.net (JIRA)

unread,
Apr 15, 2020, 2:10:04 AM4/15/20
to jenkinsc...@googlegroups.com
Nils Gerke closed an issue as Not A Defect
 
Change By: Nils Gerke
Status: Resolved Closed
Reply all
Reply to author
Forward
0 new messages