Consider this Jenkins pipeline snippet using parallel to run two stages simultaneously:
pipeline {
agent any
stages {
stage('Parallel Stage') {
parallel {
stage('A') {
steps {
echo 'Running A'
}
}
stage('B') {
steps {
echo 'Running B'
}
}
}
}
}
}What will be the order of the output lines in the Jenkins console?
pipeline {
agent any
stages {
stage('Parallel Stage') {
parallel {
stage('A') {
steps {
echo 'Running A'
}
}
stage('B') {
steps {
echo 'Running B'
}
}
}
}
}
}Think about how parallel execution affects output order.
Parallel stages run simultaneously, so their output lines can appear in any order or interleaved in the Jenkins console.
Which of the following Jenkins scripted pipeline snippets correctly defines two parallel stages named 'Test' and 'Build'?
parallel(
Test: {
echo 'Testing'
},
Build: {
echo 'Building'
}
)Remember scripted pipeline uses parallel with a map of closures.
In scripted pipeline, parallel takes a map where keys are stage names and values are closures with steps. Option A matches this syntax exactly.
A Jenkins declarative pipeline uses parallel to run three branches: 'Lint', 'Test', and 'Deploy'. However, only 'Lint' and 'Test' run, and 'Deploy' is skipped without error. What is the most likely cause?
Check conditions that control stage execution.
If a stage has a when condition that evaluates to false, Jenkins skips it silently even in parallel blocks.
Given this Jenkins declarative pipeline snippet:
pipeline {
agent any
stages {
stage('Main') {
parallel {
stage('Branch1') {
steps { echo 'Branch1' }
}
stage('Branch2') {
parallel {
stage('Sub1') {
steps { echo 'Sub1' }
}
stage('Sub2') {
steps { echo 'Sub2' }
}
}
}
}
}
}
}Which statement about the output order is true?
Think about how nested parallel blocks behave.
All parallel branches, including nested ones, run concurrently, so their output can appear in any order or interleaved.
In a Jenkins pipeline with multiple parallel stages, what is the best practice to ensure that if one stage fails, the others continue running and the pipeline reports the failure at the end?
Consider how to isolate failures and still report them.
Wrapping each parallel stage in try-catch allows stages to continue running despite failures and lets you record and report failures explicitly at the end.