Weird Flow using Lists and Jenkins pipeline parallel

17 views
Skip to first unread message

Isaac Aymerich

unread,
Nov 26, 2016, 11:06:21 AM11/26/16
to Jenkins Users
this work as I expect
stage("paralelo"){
       def paralelo=[:]
       for(def counter=1;counter<6;counter++){
           def value=counter
           paralelo["branch${counter}"] = {
               print "hello ${value}"
               if(value==5){
                   error 'died'
               }
           }
       }

        catchError{
           parallel paralelo
       }
   }


but if we move
def value=counter

inside
 paralelo["branch${counter}"] = {


all the parallel executions get the same value in $counter variable (last value)

anybody could explain me what exactly is happening?

Thank you
Reply all
Reply to author
Forward
0 new messages