Just to follow up, I found a solution.  The code looks like this:

version = "4.1.0"
println "Deploying version " + version
def jobsList =  ["test1,test2"] - list of jobs, but first element has all 
jobs
def jobNamesString= jobsList.get(0) // Get the comma delimited string of 
job names
def jobs= jobNamesString.split(',') // Creates an array of jobNames that 
can be iterated
// construct and collect closures for LATER execution
buildClosures = []
for (int i = 0; i < jobs.size(); i++) {
   def jobName = jobs[i]
   def curClosure = {
        build(jobName,Version:version)
    }
    buildClosures.add(curClosure)
}


// execute the closures in buildClosures in parallel
parallel(buildClosures)

*And here is the Console output:*

Deploying version 4.1.0
parallel {
    Schedule job test1
    Schedule job test2
    Build test1 #12 started
    Build test2 #10 started
    test1 #12 completed 
    test2 #10 completed 
}
Finished: SUCCESS

This post was a big help:  
http://jenkins-ci.361315.n4.nabble.com/BUILD-FLOW-parallel-closure-simple-example-td4699743.html

On Wednesday, September 16, 2015 at 10:34:26 PM UTC-5, Jay Neese wrote:
>
> I am using a similar configuration as OP, except that multiple *different* 
> jobs must be ran in parallel.  I have two separate build jobs (test1 and 
> test2)  that are being fed into the parallel function and rather than 
> running jobs test1 and test2, it is running test2 twice.  In my case the 
> jobs will be different, but the parameter (version) that is passed to the 
> jobs will not change. 
>
> *Here is the code:*
>
> version = "4.1.0" 
> println "Deploying version " + version 
> def components =  ["test1,test2"] 
> println components 
> def component = components.get(0) 
> println component 
> def values = component.split(',') 
> def jobsInParallel = []; 
> for ( myComponent  in values ) { 
>   println myComponent 
>   def parallelJob = { 
>     def jobParams = [:] 
>     jobParams = myComponent 
>     println jobParams 
>     build (jobParams,Version:version) 
>   } 
>   jobsInParallel.add(parallelJob) 
> } 
> parallel(jobsInParallel)
>
>
> *And here is the Console output:*
>
> Deploying version 4.1.0
> [test1,test2]
> test1,test2
> test1
> test2
> parallel {
> test2
> test2
>     Schedule job test2
>     Schedule job test2
>     Build test2 #1 started
>     Build test2 #1 started
>     test2 #1 completed 
>     test2 #1 completed 
> }
> Finished: SUCCESS
>
>
>
> Any ideas on why the test1 job isn't being included in the parallel build? 
>  Any help would be appreciated. 
>
> Thank You, 
>
> Jay
>
>
> On Monday, February 17, 2014 at 4:13:35 PM UTC-6, Stuart Rowe wrote:
>>
>> Hi Rodrigo, 
>>
>> BuildFlow's parallel function takes a list or map of closures - it will 
>> execute each in parallel. 
>>
>> For your situation, you should iterate over your list of servers, 
>> creating a 
>> closure for each and adding it to list. This list can the be passed as an 
>> argument to parallel(). 
>>
>> e.g. 
>>
>> // create a closure for the deploy job for each server 
>> def serverDeployJobs = [] 
>> for (server in servers) { 
>>     def deployJob = { 
>>         def jobParams = [:] 
>>         // set up params for deploy job on current server here... 
>>         
>>         // call build 
>>         build(jobParams, DeployProjectName) 
>>     } 
>>     serverDeployJobs.add(deployJob) 
>> } 
>>
>> // schedule deploy jobs in parallel 
>> parallel(serverDeployJobs) 
>>
>> Hope that helps, 
>> Stuart 
>>
>>
>>
>> -- 
>> View this message in context: 
>> http://jenkins-ci.361315.n4.nabble.com/Generating-parallel-flow-with-Build-Flow-Plugin-tp4687604p4691098.html
>>  
>> Sent from the Jenkins users mailing list archive at Nabble.com. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/704d414b-84ab-4b30-9fe6-bfc71fed5bab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to