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
How to Build a Multibranch Pipeline in JenkinsSet up a Jenkins Multibranch Pipeline so every branch and pull request with a Jenkinsfile gets its own auto-d…
How to Publish JUnit and Coverage in JenkinsPublish JUnit test results and a coverage report in Jenkins with the junit step and the Coverage plugin, so t…