Complete the code to send an email notification in a Jenkins pipeline.
emailext to: '[1]', subject: 'Build Notification', body: 'The build is complete.'
to field empty or with an invalid email.The to field specifies the recipient email address. Here, build@company.com is the correct recipient for build notifications.
Complete the code to trigger email notification only when the build fails.
post {
failure {
emailext to: 'build@company.com', subject: 'Build Failed', body: '[1]'
}
}The email body should inform that the build failed, so 'The build has failed. Please check the logs.' is the correct message.
Fix the error in the email notification syntax to send to multiple recipients.
emailext to: '[1]', subject: 'Build Status', body: 'Check the build details.'
Multiple email addresses should be separated by commas in the to field.
Fill both blanks to send an email only when the build is unstable and include the build URL in the body.
post {
[1] {
emailext to: 'build@company.com', subject: 'Build Unstable', body: '[2]'
}
}success instead of unstable.The unstable block triggers on unstable builds. The env.BUILD_URL provides the build URL to include in the email body.
Fill all three blanks to create a map of email parameters with recipient, subject, and body including the build status.
def emailParams = [to: '[1]', subject: '[2]', body: "[3]"] emailext emailParams
The to field is set to the QA team email. The subject is a general notification. The body includes the build status dynamically using currentBuild.currentResult.