-
Bug
-
Resolution: Not A Defect
-
Minor
-
None
running this pipeline:
def do_i(p) {
return {
echo "$p"
for (i = 0; i < 10; i++)
}
}
stage('i'){
parallel(
"x" : do_i('xx'),
"y" : do_i('yy')
)
}
produces this output:
[Pipeline] stage
[Pipeline] {
[Pipeline] parallel
[Pipeline] [x] { (Branch: x)
[Pipeline] [y]
[Pipeline] [x] echo
[x] i: 10
[Pipeline] [x] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Note how i is incremented as if both threads were referring to the same variable i.
If I modify the for loop to: for (int i = 0; i < 10; i++)
then it works as I expect, where each thread has its own i variable:
[Pipeline] stage
[Pipeline] {
[Pipeline] parallel
[Pipeline] [x] { (Branch: x)
[Pipeline] [y]
[Pipeline] [y] echo
[y] i: 9
[Pipeline] [y] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline