0
0
Jenkinsdevops~10 mins

Parallel stages execution in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Parallel stages execution
Start Pipeline
Define Parallel Stages
Wait for all stages to finish
Continue with next steps
The pipeline starts, defines multiple stages to run at the same time, runs them all together, waits for all to finish, then moves on.
Execution Sample
Jenkins
pipeline {
  agent any
  stages {
    stage('Parallel Stages') {
      parallel {
        stage('Stage A') { steps { echo 'A' } }
        stage('Stage B') { steps { echo 'B' } }
        stage('Stage C') { steps { echo 'C' } }
      }
    }
  }
}
This Jenkins pipeline runs three stages named A, B, and C at the same time.
Process Table
StepActionStage RunningOutputNotes
1Start pipelineNonePipeline begins execution
2Enter 'Parallel Stages' stageNonePreparing parallel stages
3Start Stage AStage AAStage A runs echo 'A'
3Start Stage BStage BBStage B runs echo 'B'
3Start Stage CStage CCStage C runs echo 'C'
4Wait for all stages to finishStage A, B, CAll parallel stages complete
5Continue pipelineNonePipeline moves to next steps or ends
💡 All parallel stages complete, pipeline continues
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Stage A StatusNot startedNot startedRunningCompletedCompleted
Stage B StatusNot startedNot startedRunningCompletedCompleted
Stage C StatusNot startedNot startedRunningCompletedCompleted
Pipeline StatusNot startedRunningRunningWaitingRunning or Finished
Key Moments - 3 Insights
Why do all stages start at the same step number 3 in the execution table?
Because the stages run in parallel, they start simultaneously at the same step, as shown in rows with step 3.
What happens if one parallel stage fails before others finish?
The pipeline waits for all parallel stages to finish or fail before continuing, ensuring synchronization as shown in step 4.
How does Jenkins know when to move on after parallel stages?
Jenkins waits until all parallel stages report completion, indicated in step 4, before moving to the next pipeline step.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step do all parallel stages start running?
AStep 4
BStep 2
CStep 3
DStep 5
💡 Hint
Check the 'Stage Running' column in the execution table rows with step 3.
According to the variable tracker, what is the status of Stage B after step 4?
ANot started
BCompleted
CRunning
DFailed
💡 Hint
Look at the 'Stage B Status' row under 'After Step 4' in the variable tracker.
If Stage C took longer to finish, which step in the execution table would be delayed?
AStep 4
BStep 3
CStep 5
DStep 2
💡 Hint
Step 4 waits for all parallel stages to finish, so a delay in Stage C affects step 4.
Concept Snapshot
Jenkins Parallel Stages Execution:
- Use 'parallel' block inside a stage to run multiple stages at once.
- All parallel stages start simultaneously.
- Pipeline waits for all to finish before continuing.
- Useful to speed up builds by doing tasks in parallel.
- Syntax: stage { parallel { stage1 { steps } stage2 { steps } } }
Full Transcript
This visual execution shows how Jenkins runs parallel stages. The pipeline starts and reaches a stage that defines multiple parallel stages. All these stages start running at the same time, shown at step 3. Each stage runs its commands independently and outputs its result. Jenkins waits until all parallel stages finish, as shown in step 4, before moving on to the next steps. The variable tracker shows the status of each stage changing from not started to running to completed. Key points include that parallel stages start simultaneously, the pipeline waits for all to finish, and this helps speed up the build process by doing tasks at the same time.