pipeline { agent any stages { stage('Explore bug') { steps { script { int maxIndex1=3 def loopers1 = [:] for (int loopIndex1 = 0; loopIndex1 < maxIndex1; loopIndex1++) { echo "loopIndex1=${loopIndex1}" loopers1["loop-${loopIndex1}"] = { echo "loopIndex1=${loopIndex1}" } } parallel loopers1 } } } stage('Bug workaround') { steps { script { int maxIndex2=3 def loopers2 = [:] for (int loopIndex2 = 0; loopIndex2 < maxIndex2; loopIndex2++) { int index2=loopIndex2 echo "index2=${index2}" loopers2["loop-${index2}"] = { echo "index2=${index2}" } } parallel loopers2 } } } } }