jenkins-发送allure邮件测试报告
1、安装插件 allure-jenkins-plugin
2、在全局工具配置中,配置allure命令行
3、全局工具配置中,添加JDK配置
4、配置slave节点工具(JDK+Allure)-配置在节点上的工具路径
5、Job中,构建后操作-添加allure报告输出配置。
参考链接: https://yq.aliyun.com/articles/664249?spm=a2c4e.11153940.blogcont664250.18.373242e6uqgm7V python+pytest单元测试框架之在Jenkins上生成Allure测试报告
.在Jenkins的页面中点击“系统管理”->"管理插件",搜索“allure”,在搜索结果页,选择“Allure Jenkins Plugin”进行安装。安装完成之后重启一下Jenkins。
![img_e0f7f0708ba924a0ca9258f548191b65.png](https://yqfile.alicdn.com/img_e0f7f0708ba924a0ca9258f548191b65.png)
Jenkins界面
![img_e871151d9d26c47772d51a545f64a62f.png](https://yqfile.alicdn.com/img_e871151d9d26c47772d51a545f64a62f.png)
安装Allure插件
![img_496feaf47f3fa970e3f3011828dcba13.png](https://yqfile.alicdn.com/img_496feaf47f3fa970e3f3011828dcba13.png)
安装过程
![img_cfd89f4fd703c16308d7ad5f033f2e84.png](https://yqfile.alicdn.com/img_cfd89f4fd703c16308d7ad5f033f2e84.png)
安装完成
![img_2ac7b25017e9442716fdcaf103b43498.png](https://yqfile.alicdn.com/img_2ac7b25017e9442716fdcaf103b43498.png)
重启Jenkins
![img_f2d72b15ff3ed9392d30dea6958f2963.png](https://yqfile.alicdn.com/img_f2d72b15ff3ed9392d30dea6958f2963.png)
查看安装好的插件1
2、在全局工具配置中,配置allure命令行
![img_72bee8ef6ba14778bda543b722e14753.png](https://yqfile.alicdn.com/img_72bee8ef6ba14778bda543b722e14753.png)
Global Tool Configuration管理界面
![img_08379f82c9a4831d269b1ffabf857035.png](https://yqfile.alicdn.com/img_08379f82c9a4831d269b1ffabf857035.png)
安装Allure Commandline
![img_a91091b48e4c1ef550dcb409175b6cd3.png](https://yqfile.alicdn.com/img_a91091b48e4c1ef550dcb409175b6cd3.png)
保存Allure配置
3、全局工具配置中,添加JDK配置
4、配置slave节点工具(JDK+Allure)-配置在节点上的工具路径
5、配置Job,构建后操作-添加allure报告输出配置。
1、在Jenkins主界面,进入 jenkins 持续集成项目配置界面
![img_90eb2897428f12799fdc4030f5effbd2.png](https://yqfile.alicdn.com/img_90eb2897428f12799fdc4030f5effbd2.png)
配置report路径
四、查看运行结果
![img_eafca94a6071578c54b3af94cebf553a.png](https://yqfile.alicdn.com/img_eafca94a6071578c54b3af94cebf553a.png)
运行用例
![img_af3493cea49ff1633da981378a1c0325.png](https://yqfile.alicdn.com/img_af3493cea49ff1633da981378a1c0325.png)
运行结果1
![img_21afee65461d1019bf9a635f477576bf.png](https://yqfile.alicdn.com/img_21afee65461d1019bf9a635f477576bf.png)
运行结果2
![img_81aac9ac37e71dc22c63d8a9fe9d2bd9.png](https://yqfile.alicdn.com/img_81aac9ac37e71dc22c63d8a9fe9d2bd9.png)
运行结果3
![img_07a481b83addd7e61d799784d6838f54.png](https://yqfile.alicdn.com/img_07a481b83addd7e61d799784d6838f54.png)
运行结果4
jenkins发送测试报告邮件
1.安装插件 Email Extension Plugin
2.设置Extended E-mail Notification
![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428151127529-786840899.png)
a."系统管理"--“系统设置”。配置Extended E-mail Notification--“高级”
3.jenkins任务配置a. 任务配置界面--构建后操作--增加构建后操作步骤
邮件内容(一)
邮件样式:![](https://img2018.cnblogs.com/blog/979598/201905/979598-20190528172841176-842154805.png)
邮件内容(二)
![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428155319279-1935907555.png)
立即构建后,收件人邮箱收到的报告如下:![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428170820952-1028947992.png)
![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428154640876-653418002.png)
![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428170221902-178761211.png)
<h1><center><font>以下是Jenkins自动发送的邮件,请勿回复!</font><center></h1> <h3><center><font color="red">allure报告在线查看or下载allure-report.zip用firefox离线查看,测试用例见附件</font><center></h3> <br> <hr> <br> 项目描述:${JOB_DESCRIPTION}<br> <br> <hr> 项目名称:$PROJECT_NAME<br> 构建编号:$BUILD_NUMBER<br> 构建状态:$BUILD_STATUS<br> 触发原因:${CAUSE}<br> 构建地址:<A HREF="${BUILD_URL}">${BUILD_URL}</A><br> 构建日志地址:<A HREF="${BUILD_URL}console">${BUILD_URL}console</A><br> 系统allure测试报告:<A HREF="${PROJECT_URL}${BUILD_NUMBER}/allure">${PROJECT_URL}${BUILD_NUMBER}/allure</a><br> <hr> ${JELLY_SCRIPT}
![](https://img2018.cnblogs.com/blog/979598/201905/979598-20190528172841176-842154805.png)
![](https://img2018.cnblogs.com/blog/979598/201905/979598-20190528172921251-510423804.png)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${ENV, var="JOB_NAME"}-第${BUILD_NUMBER}次构建日志</title>
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4"
offset="0">
<h3>以下是Jenkins自动发送的邮件,请勿回复!</h3>
<div>
<table width="95%" cellpadding="0" cellspacing="0"
style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<th><br />
<h2>构建信息</h2>
</th>
</tr>
<tr>
<td>
<ul>
<li>项目名称 : ${PROJECT_NAME}</li><br />
<li>系统的测试报告 : <a href="${PROJECT_URL}${BUILD_NUMBER}/allure">${PROJECT_URL}${BUILD_NUMBER}/allure</a></li><br />
<li>触发原因: ${CAUSE}</li><br />
<li>项目 Url : <a href="${PROJECT_URL}">${PROJECT_URL}</a></li><br />
</ul>
</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<th><br />
<h2>测试报告</h2>
</th>
</tr>
<tr>
<td>
<div>${FILE ,path="D:/jenkins/workspace/testlogin/allure-report/index.html"}</div>
</td>
</tr>
</table>
</div>
</body>
</html>
<div>${FILE ,path="D:/jenkins/workspace/testlogin/allure-report/index.html"}</div>表示的把html的内容显示出来.
在邮件中看到的测试报告内容为空!(这个问题还不知道是什么原因)
allure报告直接访问地址时,访问不了(chorme不能查看,firefox可查看),在“高级”里设置邮件的触发条件:
![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428155319279-1935907555.png)
![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428170037828-106408311.png)
![](https://img2018.cnblogs.com/blog/1430396/201904/1430396-20190428170820952-1028947992.png)