Jenkins Pipeline: Send e-mail notifications
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
examples/jenkins/notify.gvy
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') } }
Published on 2018-08-21
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post