Last active
February 27, 2017 08:17
-
-
Save tknerr/83c6e94f2fed1dc01e4f71e3263fd4b2 to your computer and use it in GitHub Desktop.
Trying to run steps on many slaves in parallel, but when the `doStuff(x)` closure is executed the slave name argument being passed (`x`) is always "slave3"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def onEachSlave(doStuff) { | |
def doStuffClosures = [:] | |
for (slave in ['slavelnx1', 'slavelnx2', 'slavelnx3']) { | |
def s = slave | |
doStuffClosures[s] = { echo "running on ${s}..."; doStuff(s); echo "...done on ${s}!" } | |
} | |
return doStuffClosures | |
} | |
parallel(onEachSlave { slave -> | |
echo "doing stuff on ${slave}..." | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Pipeline] parallel | |
[Pipeline] [slavelnx1] { (Branch: slavelnx1) | |
[Pipeline] [slavelnx2] { (Branch: slavelnx2) | |
[Pipeline] [slavelnx3] { (Branch: slavelnx3) | |
[Pipeline] [slavelnx1] echo | |
[slavelnx1] running on slavelnx1... | |
[Pipeline] [slavelnx2] echo | |
[slavelnx2] running on slavelnx2... | |
[Pipeline] [slavelnx3] echo | |
[slavelnx3] running on slavelnx3... | |
[Pipeline] [slavelnx1] echo | |
[slavelnx1] doing stuff on slavelnx3 | |
[Pipeline] [slavelnx1] echo | |
[slavelnx1] ...done on slavelnx1! | |
[Pipeline] [slavelnx1] } | |
[Pipeline] [slavelnx2] echo | |
[slavelnx2] doing stuff on slavelnx3 | |
[Pipeline] [slavelnx2] echo | |
[slavelnx2] ...done on slavelnx2! | |
[Pipeline] [slavelnx2] } | |
[Pipeline] [slavelnx3] echo | |
[slavelnx3] doing stuff on slavelnx3 | |
[Pipeline] [slavelnx3] echo | |
[slavelnx3] ...done on slavelnx3! | |
[Pipeline] [slavelnx3] } | |
[Pipeline] // parallel | |
[Pipeline] End of Pipeline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment