配置Extended E-mail Notification
在Dashboard-->Configure System中,如果只配置了邮件通知,而没有配置Extended E-mail Notification,会导致测试邮件发送功能成功,但在pipline执行的时候不会收到邮件
测试邮件发送功能
如何配置Credentials
在新的jenkins中,这一部分的使用SMTP认证功能变成了Credentials
添加一个认证,这里的用户名就是发件人的邮箱账户,密码就是邮箱的SMTP授权码
pipline 邮件发送的脚本
pipeline {
agent any
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
}
post {
success {
emailext (
subject: "SUCCESSFUL: '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>SUCCESSFUL: '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
to: "[email protected]",
from: "[email protected]"
)
}
failure {
emailext (
subject: "FAILED: '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>FAILED: '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
to: "[email protected]",
from: "[email protected]"
)
}
}
}