Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a parallel block in Jenkins pipeline.
Jenkins
pipeline {
agent any
stages {
stage('Build and Test') {
steps {
[1] {
stage('Build') {
steps {
echo 'Building...'
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
}
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sequence' instead of 'parallel' causes stages to run one after another.
Using 'matrix' is for different combinations, not parallel execution.
✗ Incorrect
The parallel block allows multiple stages to run at the same time in Jenkins pipeline.
2fill in blank
mediumComplete the code to name a parallel stage in Jenkins pipeline.
Jenkins
pipeline {
agent any
stages {
stage('Parallel Work') {
steps {
parallel(
[1]: {
echo 'Running task A'
},
TaskB: {
echo 'Running task B'
}
)
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes causes syntax errors.
Using unquoted names is invalid in this context.
✗ Incorrect
Parallel stage names must be strings, so they need quotes like 'TaskA'.
3fill in blank
hardFix the error in the parallel stages syntax.
Jenkins
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]
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ')' or ']' causes syntax errors.
Missing the closing brace breaks the pipeline.
✗ Incorrect
The parallel block uses curly braces { }, so it must be closed with }.
4fill in blank
hardFill both blanks to correctly define parallel stages with named tasks.
Jenkins
pipeline {
agent any
stages {
stage('Parallel Tasks') {
steps {
parallel(
[1]: {
echo 'Task 1 running'
},
[2]: {
echo 'Task 2 running'
}
)
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted names causes errors.
Using same names for both tasks causes conflicts.
✗ Incorrect
Parallel stages need unique string names as keys, like 'Task1' and 'Task2'.
5fill in blank
hardFill all three blanks to create a parallel block with three stages named Build, Test, and Deploy.
Jenkins
pipeline {
agent any
stages {
stage('CI Pipeline') {
steps {
parallel(
[1]: {
echo 'Building...'
},
[2]: {
echo 'Testing...'
},
[3]: {
echo 'Deploying...'
}
)
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted names causes syntax errors.
Using incorrect or duplicate names confuses the pipeline.
✗ Incorrect
Each parallel stage must have a unique string name: 'Build', 'Test', and 'Deploy'.