前言
Jenkins本身提供的Email插件功能实在有限,只能提供当前Job的基本信息,比如成功、失败以及不稳定的状态给设定的接收着。我在搭建基于Jenkins+Robot framework的自动化测试平台过程中需要在每个自动化的测试Job结束后根据当前测试的结果向设定的接收着发送测试报告,要求测试报告的标题及紧急程度按照成功或者失败来确定。我的第一个想法就是使用Java的Email Libray然后在Job结束后去调用发送邮件功能,之前也一直是这么做的,但自从发现标题中的plugin后发现自己之前使用的方法好low,下面就是我对_Editable Email Notification_这个插件的使用总结。
需求描述
Job启动参数在启动Job时指定,所有参数都带有默认值;
Check out code from git server;
Execute Automation launch shell script, this script file saved in git;
The shell script will launch automation testing with parameters;
Wait until automation testing finished, decide current job success or failure upon the return value return from testing process;
Send success or failure Email notification to receivers decided by job execute status.
插件主要设置参数描述
下面主要介绍了Email插件中主要参数的设置,由于本人的Jenkins为英文版,所以参数全部为英文,请使用中文的朋友自行对应设置即可。
Content Type: Both HTML and Plain Text
在邮件的正文中要插入HTML代码,所以在Content Type中要选择支持HTML和富文本
Attach Build Log: Do Not Attach Build Log
在邮件的附件中需要携带automation的详细report,所以不需要带Job本身的log信息
Pre-send Script:
// 下面所有的代码都会被执行到,只能支持Java内置的Library,使用之前一定要importimport java.text.SimpleDateFormat;import java.util.Date;im