Jenkins 配置邮件发送
- 登录之后点击,系统设置:
2.系统管理员的邮箱要和发送邮件的邮箱保持一致:
3.系统默认邮箱配置(点击高级之后才可以看到所有配置):
4.验证邮箱配置(填写一个可以邮件的邮箱,点击 Test Configuration)
如果配置正确你test@163.com 邮箱就会收到jenkins 测试邮件
- 我们再配置一下jenkins 邮件扩展插件的配置,同样点击高级之后才能展示所有选项:
和默认邮箱的配置基本差不多,不过这个可以编辑邮件的内容。
你的邮件内容格式可以定义在 Default Content 里面。
最后是在你的job 中配置邮件信息,和触发条件:
添加构建后操作->Editable Email Notification
填写: Project Recipient List, 不会写,就点一下帮助文档
Content Type 选择:html(text/html)
其他的默认就行了
最后点击 Advanced Settings->Add Trigger->
选择邮件发送的触发类型
最后附上我自己配置的一个邮件模板:
<!-- ####### YAY, I AM THE SOURCE EDITOR! #########-->
<body>
<head>
<STYLE TYPE="text/css">
BODY {
background-image: URL(http://pic1.win4000.com/wallpaper/2/57887791aba6b.jpg);
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size:100% 100%;
}
</STYLE>
</head>
<h2 style="color: #5e9ca0; text-align: center;">PS:(本邮件是自动化测试邮件,请勿回复!)</h2>
<table class="editorDemoTable" style="height: 273px;" width="430">
<thead>
<tr>
<td nowrap="nowrap" style="background-color: #3498db; text-align: center;" colspan="2">
<h2><span style="color: #000000;">自动化测试报告</span></h2>
</td>
</tr>
</thead>
<tbody>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">项目名称:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">$PROJECT_NAME</span></td>
</tr>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">构建编号:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">$BUILD_NUMBER</span></td>
</tr>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">构建状态:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">$BUILD_STATUS</span></td>
</tr>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">触发原因:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">${CAUSE}</span></td>
</tr>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">构建日志地址:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #00ccff;"> <a style="color: #00ccff;" title="构建日志" href="${BUILD_URL}console">${BUILD_URL}console</a></span></td>
</tr>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">构建地址:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #00ccff;"> <a style="color: #00ccff;" title="构建地址" href="$BUILD_URL">$BUILD_URL</a></span></td>
</tr>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">测试报告地址:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #00ccff;"><a style="color: #00ccff;" title="测试报告地址" href="${BUILD_URL}robot/report/report.html">${BUILD_URL}robot/report/report.html</a></span></td>
</tr>
<tr>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #808000;">测试日志地址:</span></td>
<td nowrap="nowrap" style="border-color: gray;"><span style="color: #00ccff;"> <a style="color: #00ccff;" title="测试日志地址" href="${BUILD_URL}robot/report/log.html">${BUILD_URL}robot/report/log.html</a></span></td>
</tr>
</tbody>
</table>
</body>