说明:通过配置jenkins邮件通知,以达到根据构建结果以邮件方式通知到对应的负责人
1.安装插件:Email Extension Plugin
2.配置SMTP服务器:jenkins → 系统管理 → 系统设置 → Extended E-mail Notification(具体如下)
SMTP server:smtp.global-mail.cn
Advance Setting中使用smtp authentication,填入用户名和密码
Use SSL:勾选
SMTP port:465
3.安装邮件通知模版
- 在JENKINS_HOME(jenkins家目录)目录下创建email-templates目录,注意属主属组要和jenkins运行用户保持一致
- 模版下载地址:https://raw.githubusercontent.com/jenkinsci/email-ext-plugin/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template
- 模版下载到email-templates目录中,并保存
4.配置JOB中的邮件通知
- 在Post-build Actions选择Editable Email Notification
- Project Recipient List 填写收件人邮箱地址,多个地址以","隔开
- Content Type 选择 HTML(text/html)
- Default Content 填写:${SCRIPT, template="groovy-html.template"}
- 在Advanced Settings中,Triggers → Failure - Any → Send To → Recipient List 如下图
- 最后保存