Post-build actions are steps Jenkins performs after the main build finishes, like sending notifications, archiving files, or triggering other jobs.
Click to reveal answer
beginner
Name two common post-build actions in Jenkins.
Common post-build actions include 'Archive the artifacts' to save build files and 'Email Notification' to alert team members about build results.
Click to reveal answer
beginner
How do you add a post-build action in a Jenkins job?
In the job configuration, scroll to the 'Post-build Actions' section and select the desired action from the dropdown menu.
Click to reveal answer
intermediate
What happens if a post-build action fails in Jenkins?
If a post-build action fails, Jenkins usually marks the build as unstable or failed depending on the action, but the main build steps are already complete.
Click to reveal answer
intermediate
Can post-build actions trigger other Jenkins jobs? How?
Yes, using the 'Build other projects' post-build action, Jenkins can start other jobs after the current build finishes.
Click to reveal answer
What is the main purpose of post-build actions in Jenkins?
ATo write the build script
BTo compile the source code
CTo perform tasks after the build completes
DTo configure the Jenkins server
✗ Incorrect
Post-build actions are tasks Jenkins runs after the build finishes, like notifications or archiving.
Which post-build action would you use to save build output files?
AArchive the artifacts
BEmail Notification
CBuild other projects
DDelete workspace
✗ Incorrect
'Archive the artifacts' saves files generated by the build for later use.
How can Jenkins notify team members after a build?
AUsing Email Notification post-build action
BBy restarting Jenkins
CBy compiling code
DBy running a shell script
✗ Incorrect
Email Notification is a post-build action to send emails about build results.
Where do you configure post-build actions in Jenkins?
AIn the build triggers section
BIn the source code repository
CIn the Jenkins system settings
DIn the post-build actions section of the job configuration
✗ Incorrect
Post-build actions are set in the job's configuration under the post-build actions section.
What does the 'Build other projects' post-build action do?
ADeletes other projects
BTriggers other Jenkins jobs after the current build
CCompiles other projects
DSends notifications to other projects
✗ Incorrect
'Build other projects' triggers other Jenkins jobs after the current job finishes.
Explain what post-build actions are and why they are useful in Jenkins.
Think about what happens after Jenkins finishes building your code.
You got /3 concepts.
Describe how to add and configure a post-build action to send an email notification in Jenkins.
Focus on the steps inside the Jenkins job settings.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of Post-build actions in Jenkins?
easy
A. To start the build process
B. To write the build script
C. To perform tasks automatically after the build finishes
D. To configure the Jenkins server settings
Solution
Step 1: Understand Jenkins build phases
Jenkins runs build steps first, then post-build actions after the build ends.
Step 2: Identify the role of post-build actions
Post-build actions automate tasks like notifications, archiving, or cleanup after the build completes.
Final Answer:
To perform tasks automatically after the build finishes -> Option C
Quick Check:
Post-build actions = tasks after build [OK]
Hint: Post-build actions run after build ends to automate tasks [OK]
Common Mistakes:
Confusing post-build actions with build steps
Thinking post-build actions start the build
Assuming post-build actions configure Jenkins server
2. Which of the following is the correct syntax to add a post-build action in a Jenkins pipeline script?
easy
A. build {
post {
echo 'Build finished'
}
}
B. pipeline {
postbuild {
echo 'Build finished'
}
}
C. steps {
post {
echo 'Build finished'
}
}
D. post {
always {
echo 'Build finished'
}
}
Solution
Step 1: Recall Jenkins pipeline post syntax
In declarative pipelines, post block defines post-build actions with conditions like always.
Step 2: Match syntax options
post {
always {
echo 'Build finished'
}
} uses correct post { always { ... } } syntax. Others use invalid blocks like build or postbuild.
Final Answer:
post { always { echo 'Build finished' } } -> Option D
Quick Check:
Post block syntax = post {
always {
echo 'Build finished'
}
} [OK]
Hint: Use 'post { always { ... } }' for post-build actions in pipeline [OK]
Common Mistakes:
Using 'postbuild' instead of 'post'
Placing post block inside 'steps'
Using 'build' block incorrectly
3. Given this Jenkins pipeline snippet, what will be printed after the build finishes successfully?
A. The mail step requires proper Jenkins email configuration
B. The failure block should be inside steps
C. The mail step requires a steps block inside failure
D. The post block must be inside steps
Solution
Step 1: Understand the mail step requirements
The mail step requires the 'Email Extension Plugin' to be installed and SMTP server configured in Manage Jenkins > Configure System > Extended E-mail Notification.
Step 2: Identify the likely problem
Without proper email configuration (SMTP host, port, credentials, etc.), the notification won't send even if the syntax is correct.
Final Answer:
The mail step requires proper Jenkins email configuration -> Option A
Quick Check:
Mail needs SMTP config [OK]
Hint: Configure SMTP in Jenkins for mail step [OK]
Common Mistakes:
Not installing Email Extension plugin
Not setting SMTP server details
Missing 'from' address or credentials
5. You want to archive build artifacts only if the build succeeds and always send a notification email regardless of build result. Which Jenkins pipeline post section correctly implements this?
hard
A. post {
success {
archiveArtifacts 'build/*.jar'
}
always {
mail(to: 'devs@example.com', subject: 'Build Notification')
}
}
B. post {
always {
archiveArtifacts 'build/*.jar'
mail(to: 'devs@example.com', subject: 'Build Notification')
}
}
C. post {
success {
archiveArtifacts 'build/*.jar'
mail(to: 'devs@example.com', subject: 'Build Notification')
}
}
D. post {
failure {
archiveArtifacts 'build/*.jar'
}
always {
mail(to: 'devs@example.com', subject: 'Build Notification')
}
}
Solution
Step 1: Identify conditions for each action
Archiving should happen only on success, so it goes inside success. Email should always send, so it goes inside always.
Step 2: Match options with conditions
post {
success {
archiveArtifacts 'build/*.jar'
}
always {
mail(to: 'devs@example.com', subject: 'Build Notification')
}
} correctly separates archive in success and mail in always. Others mix conditions incorrectly.
Final Answer:
post { success { archiveArtifacts 'build/*.jar' } always { mail(to: 'devs@example.com', subject: 'Build Notification') } } -> Option A
Quick Check:
Use success for archive, always for mail [OK]
Hint: Use 'success' for archive, 'always' for notifications [OK]
Common Mistakes:
Putting archive in always block
Sending mail only on success
Archiving on failure instead of success
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.