Complete the code to send an email notification after a Jenkins build.
post {
always {
emailext [1] {
to: 'team@example.com'
subject: 'Build Notification'
body: 'The build has completed.'
}
}
}The emailext send step triggers the email notification in Jenkins pipelines.
Complete the code to notify only when the build fails.
post {
[1] {
emailext send {
to: 'team@example.com'
subject: 'Build Failed'
body: 'Please check the build logs.'
}
}
}The failure block runs only when the build fails, triggering the notification.
Fix the error in the notification block to correctly send an email on unstable builds.
post {
unstable {
emailext [1] {
to: 'team@example.com'
subject: 'Build Unstable'
body: 'The build is unstable.'
}
}
}The correct step to send emails with the emailext plugin is send.
Fill both blanks to send notifications only when the build is successful and unstable.
post {
[1] {
emailext send {
to: 'team@example.com'
subject: 'Build Success'
body: 'The build succeeded.'
}
}
[2] {
emailext send {
to: 'team@example.com'
subject: 'Build Unstable'
body: 'The build is unstable.'
}
}
}The success block runs on successful builds, and unstable runs on unstable builds, sending notifications accordingly.
Fill all three blanks to send notifications with dynamic subject and body based on build status.
post {
[1] {
emailext send {
to: 'team@example.com'
subject: 'Build [2]'
body: 'The build status is [3].'
}
}
}When the build is successful, the success block runs, and the subject and body reflect the success status.