jenkins发送jemter邮件附件格式配置

原文:https://www.cnblogs.com/chenchen-tester/p/6930200.html

build.xml

<?xml version="1.0" encoding="UTF-8"?>  

<project name="zhtx_chaoshi" default="report" basedir=".">
<tstamp>
<!--format property="time" pattern="yyyyMMddkkmm" /-->
<format property="date" pattern="yyyy/MM/dd kk:mm:ss"/>
<!--kk是24小时制,KK是12小时制-->
</tstamp>
<!-- 需要改成自己本地的 Jmeter 目录-->
<property name="jmeter.home" value="D:/apache-jmeter-3.1" />
<property name="report.title" value="Jmeter_zhtxAPITestReport"/>
<!-- jmeter生成jtl格式的结果报告的路径-->
<property name="jmeter.result.jtl.dir" value="D:/Jenkins/workspace/超市自动下单/jtl" />
<!-- jmeter生成html格式的结果报告的路径-->
<property name="jmeter.result.html.dir" value="D:/Jenkins/workspace/超市自动下单/html" />
<!-- 生成的报告的前缀-->
<!-- 生成的报告的名称-->
<property name="ReportName" value="DetailsReport" />
<property name="ReportName2" value="SummaryReport" />
<!--jtl的value值是D:\Jenkins\jmxReport\jtl\TestReport+yyyyMMddhhmm.jtl-->
<!--html的value值是D:\Jenkins\jmxReport\html\TestReport+yyyyMMddhhmm.html-->
<property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}.jtl" />
<property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}.html" />
<property name="jmeter.result.htmlName2" value="${jmeter.result.html.dir}/${ReportName2}.html" /> <!-- 工程引用包 -->
<property name="lib.home" value="D:/apache-jmeter-3.1/xjar"/>
<!--jmx文件存放位置-->
<property name="jmxFile" value="D:/apache-jmeter-3.1/jmx"/> <!--项目初始化设置-->
<target name="init" description="init" >
<!--删除jtl文件夹下生成的所有文件及文件夹包括空目录,但不删除根目录-->
<delete verbose="true" includeemptydirs="true" >
<fileset dir="${jmeter.result.jtl.dir}" >
<include name="**/*" />
</fileset>
</delete>
<!--删除html文件夹下生成的所有文件及文件夹包括空目录,但不删除根目录-->
<delete>
<fileset dir="${jmeter.result.html.dir}">
<include name="**/*"/>
</fileset>
</delete>
<!--<delete dir="${classes.home}"/>
<mkdir dir="${classes.home}"/>-->
</target> <target name="test" depends="init">
<taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
<jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}">
<!-- 声明要运行的脚本。"*.jmx"指包含此目录下的所有jmeter脚本-->
<testplans dir="${jmxFile}" includes="超市订单online.jmx" />
<!--声明生成的jtl文件是xml格式,否则会报错 -->
<property name="jmeter.save.saveservice.output_format" value="xml"/>
</jmeter>
</target>
<path id="xslt.classpath">
<fileset dir="${lib.home}" includes="xalan*.jar"/>
<fileset dir="${lib.home}" includes="serializer*.jar"/>
</path> <target name="report" depends="test" > <xslt
classpathref="xslt.classpath"
force="true"
in="${jmeter.result.jtlName}"
out="${jmeter.result.htmlName}"
style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl">
<param name="titleReport" expression="${report.title}"/>
<param name="dateReport" expression="${date}"/>
</xslt>
<xslt
classpathref="xslt.classpath"
force="true"
in="${jmeter.result.jtlName}"
out="${jmeter.result.htmlName2}"
style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl">
<param name="titleReport" expression="${report.title}"/>
<param name="dateReport" expression="${date}"/>
</xslt>
<!-- 因为上面生成报告的时候,不会将相关的图片也一起拷贝至目标目录,所以,需要手动拷贝 -->
<copy todir="${jmeter.result.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png" />
<include name="expand.png" />
</fileset>
</copy>
</target> </project> build.xml

 修改D:\apache-jmeter-3.1\bin下的jmeter.properties属性文件

# assertion_results_failure_message only affects CSV output
jmeter.save.saveservice.assertion_results_failure_message=true
#
# legitimate values: none, first, all
#jmeter.save.saveservice.assertion_results=none
#
jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
#response_data is not currently supported for CSV output
jmeter.save.saveservice.response_data=true
#Save ResponseData for failed samples
jmeter.save.saveservice.response_data.on_error=false
jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=true
#jmeter.save.saveservice.assertions=true
jmeter.save.saveservice.latency=true
jmeter.save.saveservice.connect_time=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.responseHeaders=false
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.encoding=false
jmeter.save.saveservice.bytes=true
# Only available with HttpClient4
jmeter.save.saveservice.sent_bytes=true
jmeter.save.saveservice.url=false
jmeter.save.saveservice.filename=false
jmeter.save.saveservice.hostname=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.sample_count=false
jmeter.save.saveservice.idle_time=true jmeter.properties

  

 

配置Editable Email Notification

jenkins发送jemter邮件附件格式配置

设置发送邮件触发器

jenkins发送jemter邮件附件格式配置

进入jenkins系统设置下,编辑邮件配置,如图所示

jenkins发送jemter邮件附件格式配置

邮件正文内容如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${PROJECT_NAME}-第${BUILD_NUMBER}次构建日志</title>
</head> <body size="4" leftmargin="8" marginwidth="0" topmargin="8" marginheight="4"
offset="0">
<table width="95%" cellpadding="0" cellspacing="0"
style="font-size: 20pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td>(本邮件是程序自动下发的,请勿回复!)</td>
</tr>
<tr>
<td><h2>
<font color="#0000FF">构建状态 - ${BUILD_STATUS}</font>
</h2></td>
</tr>
<tr>
<td><br />
<b><font color="#0B610B">构建信息</font></b>
<hr size="3" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<li>项目名称 : ${PROJECT_NAME}</li>
<li>构建编号 : 第${BUILD_NUMBER}次构建</li>
<li>触发原因: ${CAUSE}</li>
<li>构建日志: <a href="${BUILD_URL}console">${BUILD_URL}console</a></li>
<li >变更集:${JELLY_SCRIPT,template="html"}</a></li>
<li>SummaryReport:${FILE, path="D:/Jenkins/workspace/超市自动下单/html/SummaryReport.html"}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></a></li> </ul>
<hr size="3" width="100%" align="center" />
</td>
</tr> </table>
</body>
</html>

  截图如下

jenkins发送jemter邮件附件格式配置

上一篇:Spring发送带附件邮件


下一篇:利用spring-mail模块发送带附件邮件dome