Complete the code to send an email notification after a build.
post {
[1] {
mail to: 'team@example.com', subject: 'Build Status', body: 'The build is complete.'
}
}The always block ensures the email is sent after every build, regardless of the result.
Complete the code to notify only when the build fails.
post {
[1] {
mail to: 'dev@example.com', subject: 'Build Failed', body: 'Please check the build logs.'
}
}The failure block triggers notifications only when the build fails.
Fix the error in the notification script to send email only on unstable builds.
post {
[1] {
mail to: 'qa@example.com', subject: 'Build Unstable', body: 'Check the unstable build details.'
}
}The unstable block triggers notifications only when the build is unstable.
Fill both blanks to send a Slack notification only on successful builds with a custom message.
post {
[1] {
slackSend channel: '#builds', message: [2]
}
}The success block triggers notifications only on successful builds, and the message confirms success.
Fill all three blanks to create a notification that sends an email on failure, Slack message on unstable, and logs a message always.
post {
failure {
mail to: '[1]', subject: 'Build Failed', body: 'Check logs.'
}
unstable {
slackSend channel: '[2]', message: '[3]'
}
always {
echo 'Build finished.'
}
}The email is sent to the dev team on failure, Slack alerts the QA team on unstable builds, and a log message always prints.