简体   繁体   中英

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.


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.


Someone knows why? Thx.

You are using the default SMTP port (25) which will not work with a Gmail account. Try using port 465 for SSL or port 587 for TLS.

This guide might help: http://www.360logica.com/blog/email-notification-in-jenkins/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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