I need to run a number of parameterized jobs in a parallel fashion, and
decided to try a simple example I recall seeing.
///////////////////// Build Flow TestHarness
/////////////////////////////////
// construct and collect closures for LATER execution
buildClosures = []
for (int i=1; i<50; i++) {
def curClosure = {
build("TestParameterized", Parameter: i)
}
buildClosures.add(curClosure)
}
// execute the closures in buildClosures in parallel
parallel(buildClosures)
/////////////////////////////////////////////////////////////////////////////
TestParameterized contains the simple groovy script below:
///////////////////////////////// SCRIPT
///////////////////////////////////////
import hudson.model.*
def parameter = build.buildVariableResolver.resolve("Parameter")
println "parameter:"+ parameter
def long recursiveFib(long n) {
if (n == 0) {
return 0
} else if (n == 1) {
return 1
}
return recursiveFib(n - 1) + recursiveFib(n - 2)
}
def result = recursiveFib(33)
println "recursiveFib:"+result
/////////////////////////////////////////////////////////////////////////////////
When I run this the console output in build flow testharness task is
parallel {
Schedule job TestParameterized
<http://localhost:8082/job/TestParameterized/>
Schedule job TestParameterized
<http://localhost:8082/job/TestParameterized/>
Schedule job TestParameterized
<http://localhost:8082/job/TestParameterized/>
.
.
Build TestParameterized #12
<http://localhost:8082/job/TestParameterized/12/> started
Build TestParameterized #12
<http://localhost:8082/job/TestParameterized/12/> started
Build TestParameterized #12
<http://localhost:8082/job/TestParameterized/12/> started
.
.
TestParameterized #12 <http://localhost:8082/job/TestParameterized/12/>
completed
TestParameterized #12 <http://localhost:8082/job/TestParameterized/12/>
completed
TestParameterized #12 <http://localhost:8082/job/TestParameterized/12/>
completed
.
.
Build TestParameterized #13
<http://localhost:8082/job/TestParameterized/13/> started
Build TestParameterized #13
<http://localhost:8082/job/TestParameterized/13/> started
Build TestParameterized #13
<http://localhost:8082/job/TestParameterized/13/> started
.
.
TestParameterized #13 <http://localhost:8082/job/TestParameterized/13/>
completed
TestParameterized #13 <http://localhost:8082/job/TestParameterized/13/>
completed
TestParameterized #13 <http://localhost:8082/job/TestParameterized/13/>
completed
.
.
}
Finished: SUCCESS
Which shows just two TestParameterized task being created (multiple times),
and reviewing the console for these two tasks #12, #13 the parameter passed in
is always 50.
What I was expecting to see was 50 TestParameterized jobs with increasing
parameter value 1 to 50.
What am I missing?
Thanks
--
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].
For more options, visit https://groups.google.com/d/optout.