0
0
Jenkinsdevops~5 mins

Post section (success, failure, always) in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Asuccess
Bfailure
Calways
Dunstable
Which post block runs regardless of the build result?
Aalways
Bfailure
Csuccess
Dchanged
What is a common use case for the always block in Jenkins pipelines?
ASkip steps
BSend success notifications
CTrigger only on failure
DRun cleanup tasks
If you want to send a message only when the build succeeds, which post block should you use?
Asuccess
Balways
Cfailure
Dunstable
Which of these is NOT a valid post condition in Jenkins pipelines?
Asuccess
Bfailure
Ccompleted
Dalways
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.