Recall & Review
beginner
What is the purpose of the
post section in a Jenkins pipeline?The
post section defines actions that run after the main pipeline stages, such as notifications or cleanup tasks, based on the build result.Click to reveal answer
beginner
What does the
success block inside the post section do?The
success block runs its steps only if the pipeline finishes successfully without errors.Click to reveal answer
beginner
When does the
failure block inside the post section execute?The
failure block runs its steps only if the pipeline fails during execution.Click to reveal answer
beginner
What is the role of the
always block in the Jenkins post section?The
always block runs its steps no matter if the pipeline succeeds, fails, or is aborted. It's useful for cleanup or final notifications.Click to reveal answer
intermediate
Give an example of a simple Jenkins
post section using success, failure, and always blocks.post {
success {
echo 'Build succeeded!'
}
failure {
echo 'Build failed!'
}
always {
echo 'This runs no matter what.'
}
}
Click to reveal answer
In Jenkins, which
post block runs only if the build fails?✗ Incorrect
The
failure block runs only when the build fails.Which
post block runs regardless of the build result?✗ Incorrect
The
always block runs no matter if the build succeeds, fails, or is aborted.What is a common use case for the
always block in Jenkins pipelines?✗ Incorrect
Cleanup tasks like deleting temporary files are often placed in the
always block.If you want to send a message only when the build succeeds, which
post block should you use?✗ Incorrect
The
success block runs only when the build finishes successfully.Which of these is NOT a valid
post condition in Jenkins pipelines?✗ Incorrect
There is no
completed condition; valid ones include success, failure, always, and others like unstable.Explain how the
post section works in a Jenkins pipeline and describe the roles of success, failure, and always blocks.Think about when you want to send notifications or clean up after a build.
You got /4 concepts.
Write a simple Jenkins pipeline snippet that uses the
post section to print messages on success, failure, and always.Use the <code>echo</code> step inside each block.
You got /4 concepts.