jmeter+ant+jenkins安装配置

一、jmeter下载安装

1下载地址

apache-jmeter-3.3.zip
JMeterPlugins-Extras-1.4.0.zip
JMeterPlugins-Standard-1.4.0.zip
logkit-2.0.jar.zip

2jmeter插件的安装

解压JMeterPlugins-Extras-1.4.0.zip、JMeterPlugins-Standard-1.4.0.zip,将两个文件夹lib\ext目录下的所有文件拷贝到apache-jmeter-3.3\lib\ext目录下;

3配置环境变量

JMETER_HOME
D:\jmeter\apache-jmeter-3.3
CLASSPATH
%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;%JMETER_HOME%\lib\logkit-2.0.jar;
Path
%JMETER_HOME%\bin

二、ant下载安装

1下载地址

apache-ant-1.10.5-bin.zip

2配置环境变量

ANT_HOME
D:\ant\apache-ant-1.10.5
Path
D:\ant\apache-ant-1.10.5\bin

3测试是否安装成功

4关联jmeter

将\apache-jmeter-3.3\extras下面的ant-jmeter-1.1.1的jar包到ant的lib目录

5创建build.xml

如下选择脚本和创建文件夹

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

<project name="lmh" default="run" basedir=".">
    <tstamp>
        <format property="time" pattern="yyyyMMddhhmm" />
    </tstamp>
    <!-- 需要改成自己本地的 Jmeter 目录-->  
    <property name="jmeter.home" value="D:\jmeter\apache-jmeter-3.3" />
    <!-- jmeter生成jtl格式的结果报告的路径--> 
    <property name="jmeter.result.jtl.dir" value="D:\jmeter\apache-jmeter-3.3\demo\report\jtl" />
    <!-- jmeter生成html格式的结果报告的路径-->
    <property name="jmeter.result.html.dir" value="D:\jmeter\apache-jmeter-3.3\demo\report\html" />
    <!-- 生成的报告的前缀-->  
    <property name="ReportName" value="TestReport" />
    <property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />
    <property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />
    
    <target name="run">
        <antcall target="test" />
        <antcall target="report" />
    </target>
    
    <target name="test">
        <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
        <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}">
             <!-- 声明要运行的脚本。"*.jmx"指包含此目录下的所有jmeter脚本-->
            <testplans dir="D:\jmeter\apache-jmeter-3.3\demo" includes="*.jmx" />
            <property name="jmeter.save.saveservice.output_format" value="xml"/>
        </jmeter>
    </target>
    
    <path id="xslt.classpath">
        <fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/>
        <fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/>
    </path> 
    
    <target name="report">
        <tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp>
        <xslt
              classpathref="xslt.classpath"
              force="true"
              in="${jmeter.result.jtlName}"
              out="${jmeter.result.htmlName}"
              style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl">
              <param name="dateReport" expression="${report.datestamp}"/>
        </xslt>
                <!-- 因为上面生成报告的时候,不会将相关的图片也一起拷贝至目标目录,所以,需要手动拷贝 --> 
        <copy todir="${jmeter.result.html.dir}">
            <fileset dir="${jmeter.home}/extras">
                <include name="collapse.png" />
                <include name="expand.png" />
            </fileset>
        </copy>
    </target>
</project>

5测试验证:

进入所在目录:

6问题:

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_161\lib
解决途径:
将“C:\Program Files\Java\jdk1.8.0_144\lib”目录下的tools.jar文件拷贝到“C:\Program Files\Java\jre1.8.0_161\lib”目录下,重新运行命令ant,运行正常,问题解决。

jenkins下载安装

1下载

jenkins-2.150.2.zip
解压安装

打开http://localhost:8080/

2配置JDK和ANT

选择"全局工具配置"

JDK配置

ANT配置

3插件下载

官网下载
清华镜像
htmlpublisher_1.18

4新建任务




posted @ 2019-01-17 08:31  mengnan254  阅读(999)  评论(0编辑  收藏  举报