简体   繁体   English

如何使用Jenkins发送电子邮件通知?

[英]How to send email notification with Jenkins?

I want to send a email when my build failed. 我想在构建失败时发送电子邮件。 I've configured my System Admin e-mail address : test@gmail.com and SMTP server : smtp.gmail.com. 我已经配置了系统管理员电子邮件地址 :test@gmail.com和SMTP服务器 :smtp.gmail.com。


Here's my code in my pipeline : 这是我在管道中的代码:


pipeline{
agent none
stages{
    stage('test'){
        agent{
            label 'VStest'
        }
        steps{
            script{
                //nothing
            }
        }
    }
}
post{
    always{
        mail to: 'test@gmail.com',
            subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
            body: "Something is wrong with ${env.BUILD_URL}"
        echo "sent"
      }
   }
}

I'm getting the error : 我遇到了错误:

com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. com.sun.mail.smtp.SMTPSendFailedException:530 5.7.0必须首先发出STARTTLS命令。


Someone knows why? 有人知道为什么吗? Thx. 谢谢。

You are using the default SMTP port (25) which will not work with a Gmail account. 您使用的是默认SMTP端口(25),该端口不适用于Gmail帐户。 Try using port 465 for SSL or port 587 for TLS. 尝试将端口465用于SSL或将端口587用于TLS。

This guide might help: http://www.360logica.com/blog/email-notification-in-jenkins/ 本指南可能会有所帮助: http : //www.360logica.com/blog/email-notification-in-jenkins/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM