pipeline {
agent any
stages {
stage('Parallel Tests') {
parallel {
stage('Test A') {
steps {
echo 'Running Test A'
}
}
stage('Test B') {
steps {
echo 'Running Test B'
}
}
}
}
}
}In Jenkins, stages defined inside a parallel block run at the same time. Their output messages can appear interleaved or nearly simultaneously in the console.
In declarative Jenkins pipelines, parallel stages are defined inside a parallel block with nested stage blocks, each can have its own agent and steps.
pipeline {
agent any
stages {
stage('Parallel Tests') {
parallel {
stage('Test 1') {
steps {
error 'Test 1 failed'
}
}
stage('Test 2') {
steps {
echo 'Test 2 running'
}
}
}
}
}
}By default, Jenkins runs parallel stages independently. If one fails, others continue unless failFast true is set.
The throttleConcurrentBuilds plugin allows limiting the number of concurrent builds or parallel executions to control resource usage.
Parallel stages may run on different agents or separate workspaces. Using stash and unstash steps is the recommended way to share files safely between stages.
