Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run a step only when the build succeeds.
Jenkins
post {
[1] {
echo 'Build succeeded!'
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'failure' instead of 'success'
Using 'always' when only success is needed
✗ Incorrect
The success block runs only if the build finishes successfully.
2fill in blank
mediumComplete the code to run a step only when the build fails.
Jenkins
post {
[1] {
echo 'Build failed!'
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'success' instead of 'failure'
Using 'always' when only failure is needed
✗ Incorrect
The failure block runs only if the build fails.
3fill in blank
hardFix the error in the post section to run a step regardless of build result.
Jenkins
post {
[1] {
echo 'This runs no matter what.'
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'success' or 'failure' instead of 'always'
✗ Incorrect
The always block runs no matter if the build succeeds or fails.
4fill in blank
hardFill both blanks to run steps on success and failure respectively.
Jenkins
post {
[1] {
echo 'Build succeeded!'
}
[2] {
echo 'Build failed!'
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping success and failure blocks
Using 'always' instead of specific blocks
✗ Incorrect
The success block runs on success, and failure block runs on failure.
5fill in blank
hardFill all three blanks to run steps on success, failure, and always.
Jenkins
post {
[1] {
echo 'Success block'
}
[2] {
echo 'Failure block'
}
[3] {
echo 'Always block'
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of blocks
Using 'unstable' which is not a post condition
✗ Incorrect
Use success, failure, and always blocks to run steps on those build results.