How to invoke email-ext plugin from Jenkins declarative script?

荒凉一梦 提交于 2019-12-12 12:26:36

问题


I am writing a simple Jenkins declarative script to run 'make' and send an email with the result (success/failure).

I can send a simple email using:

post {
    success {
        mail to:"myname@me.com", subject:"${currentBuild.fullDisplayName} - Failed!", body: "Success!"
    }
    failure {
        mail to:"myname@me.com", subject:"${currentBuild.fullDisplayName} - Failed!", body: "Failure!"
    }
}

The resulting email is rather simplistic.

How can I call the email-ext plugin from the script to send an old-style post-build email? (I guess this should use email-ext's groovy-text.template).

I would like to be able to access lists like CulpritsRecipientProvider and to include the tail of the console log.


回答1:


You can use it in this way:

emailext (
    subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
    body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
        <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",
    recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)

For more information you can check:

  • Sending Notifications in Pipeline
  • Email Extension Plugin


来源:https://stackoverflow.com/questions/43982256/how-to-invoke-email-ext-plugin-from-jenkins-declarative-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!