1

I have a Job made with BuildFlow, this jobs receives a parameter like job1, job2, job1 job2.

In my DSL I separate the value of the parameter with a split(","), so now I have an array with: ["job1","job2","job1 job2"].

Now i want to make the DSL run a subjob with X builds in parallel, where X is the size of the array, and iterate to get each position of the array as a paramater to pass to the build of the subjob.

Sam
  • 7,252
  • 16
  • 46
  • 65
RGonza
  • 107
  • 2
  • 10

1 Answers1

3

try this within your dsl:

subjob = "yourJobName"
subjobIteration = []

["job1","job2","job1 job2"].each{ parameter ->
  //add the closure to trigger the subjob to the list
  subjobIteration.add({build( subjob, parameter )})
}

parallel( subjobIteration )

This snippet uses the Syntax for Parallel job-executions documented here.

Groovy processes the list subjobIteration by default for the "parallel"-DSL correctly, so no further steps are needed.

lixhunter
  • 116
  • 1
  • 7
  • Is there any documentation for this? How did you know to do that? – Dr.Knowitall Dec 22 '14 at 19:03
  • It is all about Groovy. In the "Build Flow Plugin" documentation you can find the entry for parallel. The list subjobIteration consists of multiple items, that fits the syntax `{ build("yourJobName","job1") },{ build("yourJobName","job2") }` etc. The list is interpreted like that by Groovy. – lixhunter Dec 29 '14 at 22:45