Jenkins管道-通过电子邮件通知控制台错误日志 [英] Jenkins pipeline - Notify with console error log through email

查看:111
本文介绍了Jenkins管道-通过电子邮件通知控制台错误日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我已使用Jenkinsfile配置了一个作业,以在发生故障时发送通知.

Currently I have configured a job with Jenkinsfile to send notification in case of a failure .

catch (err) {
    currentBuild.result = "FAILED"
    mail (to: 'viveky4d4v@gmail.com',
         subject: "Job '${env.JOB_NAME}'- (${env.BUILD_NUMBER}) has FAILED",
         body: "Please go to ${env.BUILD_URL} for more details. ");

    throw err
}

是否可以在工作失败的情况下通过电子邮件发送控制台日志?

Is it possible to send console logs as well in the email in case of a job failure ?

推荐答案

如果您安装此处找到的电子邮件扩展插件

If you install the email extension plugin found here https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin then you can do this with another parameter. That looks like this:

emailext attachLog: true, body: '', subject: ''

这会将日志作为txt文件附件附加到您的电子邮件中,这是我个人使用的方法.

That will attach the logs as a txt file attachment to your emails, which is the method I personally use.

或者,或者,如果您不介意发送控制台日志"的意思是向控制台日志发送URL",则可以执行类似于jozefow建议的操作,并将正文更改为....

Or, alternatively, if you don't mind "sending the console logs" to mean "sending a URL to the console logs", you can do something similar to what jozefow recommended and change the body to...

body: "Please go to ${env.BUILD_URL}/consoleText for more details. ");

这篇关于Jenkins管道-通过电子邮件通知控制台错误日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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