Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Parallelism in Jenkins is defined at the Stage level which means that…

...

that a single Jenkins Pipeline is invoked, containing…

  • Some Stages configured to run sequentially

    with each Step within those Stages running sequentially

    (with their component Steps running sequentially), and/or

  • Some Stages

    configure

    configured to run concurrently

    with each Step within those Stages

    (with their component Steps running sequentially)

See Parallel stages with Declarative Pipeline 1.2 (jenkins.io)

...

Here’s a pseudocode representation of two parallel Stages defined in a Jenkins Pipeline. It runs the following stages concurrently:

  • A test (Windows command line) on any Jenkins Agent with a ‘windows’ label, and

  • A test (Unix shell) on any Jenkins Agent with a ‘linux’ label

Code Block
pipeline {
    stages {
        stage('Do These Concurrently') {
            parallel {
                stage('Test On Windows') {
                    agent {
                        label "windows"
                    }
                    steps {
                        bat "run-tests.bat"
                    }
                    post {
                        always {
                            junit "**/TEST-*.xml"
                        }
                    }
                }
                stage('Test On Linux') {
                    agent {
                        label "linux"
                    }
                    steps {
                        sh "run-tests.sh"
                    }
                    post {
                        always {
                            junit "**/TEST-*.xml"
                        }
                    }
                }
            }
        }
    }
}

...