Jenkins上配置Robot Framework测试邮件通知模板
邮件效果
测试成功如下所示:

测试失败如下所示:

通过这个模板,我们能够很直观地看出测试的执行情况,以及相关的统计信息。接下来我们详细介绍如何配置邮件模板
配置邮件模板
第一步编写邮件模板
我们的邮件模板是基于groovy脚本编写的。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<style type="text/css">
/*base css*/
a{color:#4a72af}
body{background-color:#e4e4e4}
body,p{margin:0;padding:0}
img{display:block}
h1,h2,h3,h4,h5,h6{margin:0 0 .8em 0}
h3{font-size:28px;color:#444!important;font-family:Arial,Helvetica,sans-serif}
h4{font-size:22px;color:#4a72af!important;font-family:Arial,Helvetica,sans-serif}
h5{font-size:18px;color:#444!important;font-family:Arial,Helvetica,sans-serif}
p{font-size:12px;color:#444!important;font-family:"Lucida Grande","Lucida Sans","Lucida Sans Unicode",sans-serif;line-height:1.5}
table.robotstat {
border: 1px solid black;
border-collapse: collapse;
empty-cells: show;
margin: 0px 1px;
table-layout: fixed;
word-wrap: break-word;
font-size: 1em;
border-width:1px;
}
tr.test_column_robot {
background-color:#C6C6C6;
}
ol li img{display:inline;height:20px}
/*div styles*/
.news{text-align:center;padding-top:15px;}
.content{width:720px;margin:0 auto;background-color:white}
.round_border{margin-bottom:5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;margin-top:0;font-size:14px;padding:6px;border:1px solid #ccc}
.status{background-color:<%=
build.result.toString() == "SUCCESS" ? 'green' : 'red' %>;font-size:28px;font-weight:bold;color:white;width:720px;height:52px;margin-bottom:18px;text-align:center;vertical-align:middle;border-collapse:collapse;background-repeat:no-repeat}
.status .info{color:white!important;text-shadow:0 -1px 0 rgba(0,0,0,0.3);font-size:32px;line-height:36px;padding:8px 0}
.main img{width:38px;margin-right:16px;height:38px}
.main table{font-size:14px;}
.main table th{text-align:right;}
.bottom-message{width:720px;cellpadding:5px;cellspacing:0px}
.bottom-message .message{font-size:13px;color:#aaa;line-height:18px;text-align:center}
.bottom-message .designed{font-size:13px;color:#aaa;line-height:18px;font-style: italic;text-align:right}
img.cartoon {width: 36px; display:inline}
</style>
<body>
<div class="content round_border">
<div class="status">
<p class="info">构建状态 <%= build.result.toString().toLowerCase() %></p>
</div>
<!-- status -->
<div class="main round_border">
<table>
<tbody>
<tr>
<th>项目名称:</th>
<td>${project.name}</td>
</tr>
<tr>
<th>构建轮次:</th>
<td><a
href="${rooturl}${build.url}">${build.displayName}(点击查看此轮构建信息)</a></td>
</tr>
<tr>
<th>构建时间:</th>
<td>${it.timestampString}</td>
</tr>
<tr>
<th>构建时长:</th>
<td>${build.durationString}</td>
</tr>
<tr>
<th>构建缘由:</th>
<td><% build.causes.each() { cause -> %> ${cause.shortDescription} <% } %></td>
</tr>
<tr>
<th>测试报告:</th>
<td><a
href="${rooturl}${build.url}robot">点击查看测试报告详情</a></td>
</tr>
<tr>
<!-- test stat -->
<th>测试统计:</th></br>
<td>
<table id="robotstat" class="robotstat">
<thead>
<tr id="test_column_robot" class="test_column_robot">
<th>测试总用例数</th>
<th>失败用例数</th>
<th>测试通过率</th>
</tr>
</thead>
<tbody>
<tr>
<% def robotTestResultAction = it.getAction("hudson.plugins.robot.RobotBuildAction") %>
<td>${robotTestResultAction.getTotalCount()}</td>
<td>${robotTestResultAction.getFailCount()}</td>
<td>${robotTestResultAction.getOverallPassPercentage()}%</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<th>变更记录:</th>
<td><a
href="${rooturl}${build.url}changes">点击查看变更记录</a></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</tbody>
</table>
</div>
<!-- main -->
<% def artifacts = build.artifacts
if(artifacts != null && artifacts.size() > 0) { %>
<div class="artifacts round_border">
<b>Build Artifacts:</b>
<ul>
<% artifacts.each() { f -> %>
<li><a href="${rooturl}${build.url}artifact/${f}">${f}</a></li>
<% } %>
</ul>
</div>
<% } %>
<!-- artifacts -->
<% def changeSet = build.changeSet
if(changeSet != null) {
def hadChanges = false
def count = 0 %>
<div class="details round_border">
<b>变更详细:</b>
<ol>
<% changeSet.each() { cs ->
hadChanges = true
def aUser = cs.author %>
<li>${cs.msgAnnotated} (${aUser.displayName})
(<a href="${rooturl}${build.url}changes#detail${count}">detail</a>)</li>
<% count ++
} %>
</ol>
</div>
<% } %>
<!-- details -->
</div>
<!-- content -->
<table class="bottom-message" align="center">
<tr>
<td class="message">You are receiving this email because you
are relavent with this build<br>
</td>
</tr>
<tr>
<td colspan="2" class="designed">designed by @wangyang </td>
</tr>
</table>
<!-- bottom message -->
</body>
这个邮件模板是基于groovy-html-larry.template模板改造的,我们将模板文件放到$JENKINS_HOME/email-templates目录下,如果没有这个目录,自己创建该目录。
第二步配置邮件
这里,我们需要在Jenkins安装email-ext插件,配置如下图所示:
这样的话,我们就完成了邮件模板的配置了。如果邮件发送设置正确的话,我们应该可以收到测试邮件通知。
其他
我们还可以自己编写HTML的邮件模板,而不用email-ext插件,下面是我配置效果, 执行完成后,会收到这样的邮件通知。


作者:wywincl
链接:http://www.jianshu.com/p/9368b6627a6d
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Jenkins上配置Robot Framework测试邮件通知模板的更多相关文章
- 用 Python 写 Robot Framework 测试
Robot Framework 框架是基于 Python 语言开发的,所以,它本质上是 Python 的一个库. 1.你懂 Python 语言. 2.又想使用 Robot Framework 测试框架 ...
- 【转】jenkins上配置robotframeworkride自动化脚本任务
jenkins上配置robotframeworkride自动化脚本任务 编写好的自动化脚本,集成在jenkins上进行自动运行于监控,这里采用分布式构建,在一台slave上进行任务构建与自动化脚本的运 ...
- Jenkins进阶系列之——02email-ext邮件通知模板
发现一个很好的邮件通知模板,根据我的需求定制了一些.分享一下. Default Subject: 构建通知:${BUILD_STATUS} - ${PROJECT_NAME} - Build # ${ ...
- 配置Robot Framework 环境时如何查看wxPython是否成功安装
配置Robot Framework,win10系统,安装版本分别如下:
- Jenkins email-ext邮件通知模板
http://blog.csdn.net/houyefeng/article/details/51344337 示例 以html格式发送送如下内容:邮件内容为项目名称.构建次数.触发原因.构建日志前1 ...
- Jenkins+Gitlab CE+Robot Framework持续集成
环境 Ubuntu 14.04.3 LTS Desktop 前提 1.在本地能执行测试脚本(pybot yourTestSuit.txt),本文不讲解如何学习使用RF框架 2.已有Gitlab环境,本 ...
- Robot Framework测试框架用例脚本设计方法
Robot Framework介绍 Robot Framework是一个通用的关键字驱动自动化测试框架.测试用例以HTML,纯文本或TSV(制表符分隔的一系列值)文件存储.通过测试库中实现的关键字驱动 ...
- Robot FrameWork测试案例
Robot FrameWork是一个自动测试框架,可到官网查看详细介绍. 安装 Robot Framework 本文中的Robot framework安装在Win7 (32 bit) 平台上. 接下来 ...
- Robot Framework测试框架学习笔记
一.Robot Framework框架简介 Robot Framework是一种基于Python的可扩展关键字驱动自动化测试框架,通常用于端到端的可接收测试和可接收测试驱动的开发.可以 ...
随机推荐
- 工具——代码中自动生成SVN版本号
本节和大家讨论一下程序集版本最后一位使用SVN版本号的自动生成方法,这里就向大家简单介绍一下.在进行自动部署的时候,经常需要用脚本获取程序的最新版本号.现在我们定义每个程序集的版本信息的最末段表示SV ...
- 【BZOJ 3551】[ONTAK2010] Peaks加强版 Kruskal重构树+树上倍增+主席树
这题真刺激...... I.关于Kruskal重构树,我只能开门了,不过补充一下那玩意还是一棵满二叉树.(看一下内容之前请先进门坐一坐) II.原来只是用树上倍增求Lca,但其实树上倍增是一种方法,L ...
- codevs 1078 最小生成树 kruskal
题目描述 Description 农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的农场.当然,他需要你的帮助. 约翰已经给他的农场安排了一条高速的网络线路,他想把这 ...
- 洛谷P2568 GCD (欧拉函数/莫比乌斯反演)
P2568 GCD 题目描述 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. 输入输出格式 输入格式: 一个整数N 输出格式: 答案 输入输出样例 输入 ...
- APP本地服务安全测试
一.安全测试基本分类: 1.系统安全 系统加固 安全加固:比如linux中关闭telnet端口,修改ssh端口 检测一些不必要的服务(需要卸载一个ping)--保证系统的最小集 app安全加固:加一层 ...
- Nginx support TCP Load balance
1. Install nginx package 2. edit nginx configuration file [root@ip- nginx]# more nginx.conf user ngi ...
- 动态规划:状压DP
状压DP可以用在NP问题的小规模求解中(不理解,感觉和可以搜索的题很类似) 如果状态是个网格,数据范围很小,基本锁定状压DP 例题是BZOJ1725 题意是这样的,给定一个黑白图,然后种田,要求田与田 ...
- Spring - IoC(12): 属性占位符
使用属性占位符可以将 Spring 配置文件中的部分元数据放在属性文件中设置,这样可以将相似的配置(如 JDBC 的参数配置)放在特定的属性文件中,如果只需要修改这部分配置,则无需修改 Spring ...
- usaco 月赛 2005 january sumset
2013-09-18 08:23 打表找规律 w[i]:=w[i-1]; 奇 w[i]:=w[i-1]+w[i div 2]; 偶 //By BLADEVIL var w :..] of l ...
- React事件处理程序
function ActionLink() { function handleClick(e) { e.preventDefault(); console.log('The link was clic ...