Forked from guillemcanal/jenkins-pipeline-parallel.groovy
Created
October 7, 2020 12:40
-
-
Save mvillafuertem/49a1093cdaa8a1af9a96723fa6c2a155 to your computer and use it in GitHub Desktop.
Jenkins Parallel Nodes execution
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 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