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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/61da2a57-95f1-4f2b-8c97-a9fce5d3c4d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.