Skip to content
Afa' Afa'

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

jenkinsfile
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
        }
      }
    }
  }
}
Something wrong or want to discuss this article? Get in touch

Search articles and projects

Type to filter articles and projects. Use the arrow keys to move through results and Enter to open one. Press Escape to close.