使用jenkins上执行jmeter5.2的脚本并显示报告
2020-09-29 本文已影响0人
测试星云
1、使用Ant的方式已经过时,下面是最新方式。
2、环境jmeter5.2.1 ,java8,mac/windows,jenkins2.258在本机
3、编写完成的jmeter性能脚本。调试完成后注意禁用察看结果树。否则浪费资源。脚本类似下图:

4、修改jmeter输出报告的格式为xml。在jmeter.properties的配置修改为jmeter.save.saveservice.output_format=xml,去掉#注释激活。如下图

5、在manage jenkins中的插件管理中安装performance。如下图:

6、启动jenkins服务后,新建一个自由风格的项目。
在【构建】模块选择

输出执行脚本,建立脚本在本机执行通过。如下图:
for mac:

for windows:
E:\jmeter\apache-jmeter-5.3\bin\jmeter.bat -n -t 禅道提bug.jmx -l result.jtl
F:\apache-jmeter-5.3\bin\jmeter.bat -n -t F:\apache-jmeter-5.3\jmeter\bing-soso.jmx -l result.jtl
脚本的标准格式:
jmeter.bat(Windows)/jmeter.sh(Linux) -n -t test-file [-p property-file] [-l results-file] [-j log-file] -e -o [Path to output folder])
-n是非gui(图形化方式),-t后面是测试文件,-p后面的属性文件 -l后面是输出结果文件 -j 是日志文件 -e -o 是输出的目录。
7、构建后操作:选择publish performance test result report(这个是添加插件后才有的)。保存配置。

8、执行构建多次后在performace trend中打开可以看到输出的报告转成图形显示。如果没有错误,错误的就是0.

注:
可以在配置中general中配置自定义的空间后,脚本如果在空间中的执行可不加路径。
