Skip to content

Instantly share code, notes, and snippets.

@guillemcanal
Last active October 7, 2020 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save guillemcanal/c9ebca56d2ff6433448fd3997703809c to your computer and use it in GitHub Desktop.
Save guillemcanal/c9ebca56d2ff6433448fd3997703809c to your computer and use it in GitHub Desktop.
Jenkins Parallel Nodes execution
def nodeSpecs(List specs, Closure callback) {
def nodes = [:]
for (item in specs) {
def spec = item
nodes["Spec ${spec}"] = { callback.call(spec) }
}
return nodes
}
stage("Run Unit Tests") {
parallel nodeSpecs([
[phpVersion: '5.6', symfonyVersion: '2.3'],
[phpVersion: '7.1', symfonyVersion: '3.3'],
]) { spec ->
node('docker') {
stage("Cleaning Workspace") {
deleteDir()
}
stage("Unit Tests for PHP ${spec.phpVersion}, Symfony ${spec.symfonyVersion}") {
docker.image("php:${spec.phpVersion}-alpine").inside {
sh "echo ${spec.phpVersion}"
sh "php -r 'print \"Hello ${spec.phpVersion}\" . PHP_EOL;'"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment