So looks like parallel is for running multiple hard-coded jobs in parallel. 
 No way to supply arguments to the jobs?  I even tried writing the values 
to a temp file and trying to read from it.  But looks like the for loop 
gets executed 4 times first with the last value in the temp file and the 
parallel block kicks in and reads the temp file all at once?  

On Friday, September 30, 2016 at 11:54:32 AM UTC-7, Sam K wrote:
>
> I have 4 sets of IP addresses separated by commas.  It'm converting the 
> string to a list and using the parallel block to execute them in parallel.  
>
> Problem: I am unable to get the IP addresses within the parallel blocks. 
> As you can see the branch name is interpreted properly.  However, within 
> the stage block, its not getting the value. 
>
> What is the variable I'm missing?  Thanks!
>
> *Pipeline code: *
>
> def PAIRS = '1.1.1.1 2.2.2.2, 3.3.3.3 4.4.4.4, 5.5.5.5 6.6.6.6, 7.7.7.7 
> 8.8.8.8'
>    
>    node ('jenkins-slave-1') {
>      def s = PAIRS.tokenize(',')
>      echo "Got the IP Addresses" + s
>
>      def branches = [:]
>
>      for (ip in s) {
>
>         echo "For Loop: " + ip 
>
>         branches["${ip}"] = {
>
>            stage ('pair') {
>               echo "Inside stage got this IP: " + ip
>               //echo "Inside stage:" + "${ip}"
>               sleep 5
>         }
>       }
>
>    }
>    parallel branches    
>    }    
>
> *Output:*
>
> [1.1.1.1 2.2.2.2] Inside stage got this IP:  7.7.7.7 8.8.8.8[Pipeline] 
> [1.1.1.1 2.2.2.2] sleep[1.1.1.1 2.2.2.2] Sleeping for 5 sec[Pipeline] [ 
> 3.3.3.3 4.4.4.4] echo[ 3.3.3.3 4.4.4.4] Inside stage got this IP:  7.7.7.7 
> 8.8.8.8[Pipeline] [ 3.3.3.3 4.4.4.4] sleep[ 3.3.3.3 4.4.4.4] Sleeping for 5 
> sec[Pipeline] [ 5.5.5.5 6.6.6.6] echo[ 5.5.5.5 6.6.6.6] Inside stage got this 
> IP:  7.7.7.7 8.8.8.8[Pipeline] [ 5.5.5.5 6.6.6.6] sleep[ 5.5.5.5 6.6.6.6] 
> Sleeping for 5 sec[Pipeline] [ 7.7.7.7 8.8.8.8] echo[ 7.7.7.7 8.8.8.8] Inside 
> stage got this IP:  7.7.7.7 8.8.8.8[Pipeline] [ 7.7.7.7 8.8.8.8] sleep[ 
> 7.7.7.7 8.8.8.8] Sleeping for 5 sec
>
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/3408003e-6528-450a-88e0-75746333337b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to