pytest测试报告邮件发送格式调整(基于Allure的测试报告)

背景:

  目前网上的pytest的测试报告邮件版本,都是以下格式,所有信息都需要通过链接进入,无法直观看出测试结果,而且链接进入需要登录,有些邮件接收人并没有Jenkins权限,需要能够直观真是测试结果的邮件。

解决方案: 

使用 jenkins 的 emailext 插件配置邮件正文的模板,emailext 的模板中可以使用 groovy 获取 jenkins api 和 jenkins job 的环境变量,然后获取到关键信息,展示在邮件中。(问题网上的解决方案参考:Allure Summary Email using Email-ext Jenkins Plugin 5)。

1、安装Jenkins中安装插件emailext。

2、在%JENKINS_HOME%\email-templates下放入groove脚本(如果没有email-templates,手动新建):

复制以下代码,且将脚本中的user,password改为可登陆Jenkins的账号。使用txt文件(不要用utf-8格式),另存为allure-report.groovy文件,将此文件放入%JENKINS_HOME%\email-templates下。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<style type="text/css">
/*base css*/
    body
    {
      margin: 0px;
      padding: 15px;
    }

    body, td, th
    {
      font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Tahoma, sans-serif;
      font-size: 10pt;
    }

    th
    {
      text-align: left;
    }

    h1
    {
      margin-top: 0px;
    }
    a
    {
      color:#4a72af
    }
/*div styles*/

.status{background-color:<%=
            build.result.toString() == "SUCCESS" ? 'green' : 'red' %>;font-size:28px;font-weight:bold;color:white;width:720px;height:52px;margin-botto
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值