Create parallel jenkins jobs
Define parallel stages in a Jenkins pipeline with a Groovy Jenkinsfile.
1 min read
Updated
Jenkins pipelines can run stages in parallel by building a map of closures and handing it to the parallel step. This Jenkinsfile shows the pattern with two jobs. The pipeline is reproduced below.
Jenkinsfile
text
def jobs = [:]
jobs["jobs-testa"] = {
node {
stage("Build testa") {
echo ">>> testa"
}
}
}
jobs["jobs-testb"] = {
node {
stage("Build testb") {
echo ">>> testb"
}
}
}
pipeline {
agent none
stages {
stage('Build apps(s)') {
steps {
script {
parallel jobs
}
}
}
}
}