Challenge - 5 Problems
Custom Notification Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Jenkins Pipeline: Notification on Build Status
Given the following Jenkins pipeline snippet, what will be the output notification message if the build fails?
Jenkins
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
currentBuild.result = 'FAILURE'
}
}
}
}
post {
failure {
echo 'Build failed! Sending notification to team.'
}
success {
echo 'Build succeeded! Sending success notification.'
}
}
}Attempts:
2 left
💡 Hint
Check the post section and the currentBuild.result value.
✗ Incorrect
The post block triggers the failure section when currentBuild.result is set to 'FAILURE'. So the failure message is printed.
❓ Configuration
intermediate2:00remaining
Configuring Email Notification in Jenkinsfile
Which of the following Jenkinsfile snippets correctly sends an email notification only when the build is unstable?
Attempts:
2 left
💡 Hint
Look for the post condition that matches unstable builds.
✗ Incorrect
The 'unstable' post condition triggers only when the build is unstable, so the email is sent only in that case.
❓ Troubleshoot
advanced2:00remaining
Why does the notification not send on build failure?
A Jenkins pipeline has this post block:
post {
failure {
emailext subject: 'Build Failed', body: 'Check logs.', to: 'dev@example.com'
}
}
But no email is sent when the build fails. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check plugin installation and configuration.
✗ Incorrect
If the emailext plugin is missing or misconfigured, the email step will silently fail and no email will be sent.
🔀 Workflow
advanced2:00remaining
Custom Notification Logic with Scripted Pipeline
In a scripted Jenkins pipeline, which snippet correctly sends a Slack notification only if the build result is SUCCESS or UNSTABLE?
Attempts:
2 left
💡 Hint
Use logical OR to check for multiple results.
✗ Incorrect
The condition must check if result is either 'SUCCESS' or 'UNSTABLE' using || operator.
✅ Best Practice
expert3:00remaining
Best Practice for Avoiding Duplicate Notifications in Jenkins
Which approach best avoids sending duplicate notifications when using both 'post' blocks and manual notification steps inside stages?
Attempts:
2 left
💡 Hint
Think about a single place to manage notifications.
✗ Incorrect
Centralizing notifications in the post block ensures only one notification per build status, preventing duplicates.