jmeter+ant+jenkins 搭建接口自动化测试环境

 过程参考:http://www.cnblogs.com/lxs1314/p/7487066.html

1. 安装ant

2. 安装jenkins

  

遇到问题:

  •  启动Tomcat后,访问http://localhost:8080/jenkins 报错:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Mar 23 09:05:36 CST 2018
There was an unexpected error (type=Not Found, status=404).
No message available

 是由于我本机8080端口被占用,又不能kill掉占用该端口的进程,所以去Tomcatconfigserver.xml中修改了端口号

  • 构建后操作步骤中没有HTML Report

    下载插件HTML Publisher plugin

  • 构建使用命令,运行报错 (手动cmd进入操作没问题)
D:Softapache-jmeter-4.0demo>ant
'ant' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

 操作了三步,具体是那一步的操作解决的,没深究:

1. 系统变量设置有问题,重新设置(包括用户变量的问题)

2. Jenkins设置 --> 系统管理-->全局工具配置--> ANT配置

3. 重启

构建时报错:

BUILD FAILED
D:Softapache-jmeter-4.0demouild.xml:18: The following error occurred while executing this line:
D:Softapache-jmeter-4.0demouild.xml:43: Fatal error during transformation using D:Softapache-jmeter-4.0extrasjmeter-results-detail-report_21.xsl: 前言中不允许有内容。; SystemID: file:/D:/Soft/apache-jmeter-4.0/demo/report/TestReport201803311025.jtl; Line#: 1; Column#: 1

build.xml中一定要加这一句

            <property name="jmeter.save.saveservice.output_format" value="xml"/>

报告未加载样式

出现该现象的原因在于Jenkins中配置的CSP(Content Security Policy)。 简单地说,这是Jenkins的一个安全策略,默认会设置为一个非常严格的权限集,以防止Jenkins用户在workspace、/userContent、archived artifacts中受到恶意HTML/JS文件的攻击。

解决办法:

Jenkins-->系统管理-->脚本命令行:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

重新构建生成的测试报告样式正常。

原文地址:https://www.cnblogs.com/rechin/p/8629660.html