Complete the code to define a parallel block in Jenkins pipeline.
pipeline {
agent any
stages {
stage('Build and Test') {
steps {
[1] {
stage('Build') {
steps {
echo 'Building...'
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
}
}
}
}
}The parallel block allows multiple stages to run at the same time in Jenkins pipeline.
Complete the code to name a parallel stage in Jenkins pipeline.
pipeline {
agent any
stages {
stage('Parallel Work') {
steps {
parallel(
[1]: {
echo 'Running task A'
},
TaskB: {
echo 'Running task B'
}
)
}
}
}
}Parallel stage names must be strings, so they need quotes like 'TaskA'.
Fix the error in the parallel stages syntax.
pipeline {
agent any
stages {
stage('Deploy') {
steps {
parallel {
stage('Deploy to Dev') {
steps {
echo 'Deploying to Dev'
}
}
stage('Deploy to Prod') {
steps {
echo 'Deploying to Prod'
}
}
[1]
}
}
}
}The parallel block uses curly braces { }, so it must be closed with }.
Fill both blanks to correctly define parallel stages with named tasks.
pipeline {
agent any
stages {
stage('Parallel Tasks') {
steps {
parallel(
[1]: {
echo 'Task 1 running'
},
[2]: {
echo 'Task 2 running'
}
)
}
}
}
}Parallel stages need unique string names as keys, like 'Task1' and 'Task2'.
Fill all three blanks to create a parallel block with three stages named Build, Test, and Deploy.
pipeline {
agent any
stages {
stage('CI Pipeline') {
steps {
parallel(
[1]: {
echo 'Building...'
},
[2]: {
echo 'Testing...'
},
[3]: {
echo 'Deploying...'
}
)
}
}
}
}Each parallel stage must have a unique string name: 'Build', 'Test', and 'Deploy'.
