Skip to content
Latchkey

How to Run Stages in Parallel in a Jenkins Pipeline

A parallel block runs its child stages concurrently, with optional failFast to abort the rest on the first failure.

Wrap independent stages in a parallel block inside a stage. Each branch runs at once; failFast true cancels siblings when one fails.

Parallel test branches

Lint, unit, and integration run together; failFast stops the others on the first failure.

Jenkinsfile
pipeline {
  agent any
  stages {
    stage('Checks') {
      parallel {
        stage('Lint') { steps { sh 'npm run lint' } }
        stage('Unit') { steps { sh 'npm test' } }
        stage('Integration') { steps { sh 'npm run test:int' } }
      }
    }
  }
  options { parallelsAlwaysFailFast() }
}

Notes

  • Each parallel branch can pin its own agent to spread work across nodes.
  • parallelsAlwaysFailFast() applies fail-fast to every parallel block in the pipeline.
  • Avoid having parallel branches write the same workspace files; race conditions are easy to introduce.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →