As Marc pointed out, the variable "i" isn't private to each closure because 
it's defined outside of the scope.

One solution would be to copy the value of i to a variable defined within 
the scope of the closure:


for (int i=1; i<50; i++) {
    def curClosure = {
        def j = i
        build("TestParameterized", Parameter: j)
    }
    buildClosures.add(curClosure)
}

Because each of your schedule jobs for TestParamaterized had the same 
parameters, the Jenkins scheduler actually merged the tasks to reduce 
redundancies.


On Wednesday, 23 April 2014 13:52:46 UTC-7, [email protected] wrote:
>
> Thanks for the suggestion.. .but same result
>
> On Wednesday, April 23, 2014 11:55:29 AM UTC-7, Marc MacIntyre wrote:
>>
>> I assume that you only end up defining one curClosure variable, since it 
>> never goes out of scope, and subsequent changes to it update the one 
>> version you've added to your buildClosures list.
>>
>> Maybe you want buildClosures.add(curClosure.clone()) 
>>
>

-- 
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.

Reply via email to