Configuring Jenkins to send e-mail will be covered later. For now let's see a few snippets of pipeline code that will send the e-mail.
examples/jenkins/emailtext.gvy
emailext (
subject: "Job '${env.JOB_NAME} ${env.BUILD_NUMBER}'",
body: """<p>Check console output at <a href="${env.BUILD_URL}">${env.JOB_NAME}</a></p>""",
to: "report@code-maven.com",
from: "jenkins@code-maven.com"
)
BuildUser plugin and e-mail
def notify(status) {
wrap([$class: 'BuildUser']) {
emailext (
subject: "${status}: Job ${env.JOB_NAME} ([${env.BUILD_NUMBER})",
body: """
Check console output at <a href="${env.BUILD_URL}">${env.JOB_NAME} (${env.BUILD_NUMBER})</a>""",
to: "${BUILD_USER_EMAIL}",
from: 'jenkins@company.com')
}
}