如何从Jenkins声明性脚本调用email-ext插件? [英] How to invoke email-ext plugin from Jenkins declarative script?

查看:130
本文介绍了如何从Jenkins声明性脚本调用email-ext插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个简单的Jenkins声明性脚本,以运行"make"并发送包含结果(成功/失败)的电子邮件.

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.

如何从脚本中调用email-ext插件来发送旧式的构建后电子邮件? (我猜这应该使用email-ext的groovy-text.template).

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).

我希望能够访问诸如CulpritsRecipientProvider之类的列表,并包含控制台日志的末尾.

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

推荐答案

您可以通过以下方式使用它:

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

这篇关于如何从Jenkins声明性脚本调用email-ext插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆