水莹儿 发表于 2018-1-8 14:27:02

maven+jmeter+jenkins集成

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  <modelVersion>4.0.0</modelVersion>
  

  <groupId>mavenjmeter</groupId>
  <artifactId>maven2jmeter</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  

  <name>maven2jmeter</name>
  <url>http://maven.apache.org</url>
  

  
<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <!--此文件路径是jenkins的路径,如果不用jenkins,则不能这样写,需要写项目的build路径,如: -->
  <!-- <jmeter.result.jtl.dir>${project.build.directory}\jmeter\results</jmeter.result.jtl.dir>
  <jmeter.result.html.dir>${project.build.directory}\jmeter\html</jmeter.result.html.dir>-->
  <jmeter.result.jtl.dir>${env.WORKSPACE}/Report/${env.BUILD_ID}/jtl</jmeter.result.jtl.dir>
  <jmeter.result.html.dir>${env.WORKSPACE}/Report/${env.BUILD_ID}/html</jmeter.result.html.dir>
  </properties>
  

  <dependencies>
  </dependencies>
  <build>
  <plugins>
  <plugin>
  <!-- 核心插件,用来执行jmx脚本,注意版本号,2.1.0可以使用用jmeter3.1生成的脚本。最新的2.2.0使用jmeter3.2生成的脚本 -->
  <groupId>com.lazerycode.jmeter</groupId>
  <artifactId>jmeter-maven-plugin</artifactId>
  <version>2.1.0</version>
  <configuration>
  <!-- 增加jar包,需要先将jar注册到本地maven仓库,打开cmd使用如下命令-->
  <!--mvn install:install-file -Dfile=D:\GIT\ZyzxAPIAutoTest\TXPTAPIAutoTest\plugns\jmeter-plugins-json.jar -DgroupId=com.jmeter.chajian -DartifactId=jmeter-plugins-json -Dversion=2.6 -Dpackaging=jar -->
  <jmeterExtensions>
  <!-- jmeter扩展插件 json path assert -->
  <artifact>com.jmeter.chajian:jmeter-plugins-json:2.6</artifact>
  <!-- 本地自己写的jar-->
  <artifact>com.smrz:smrz-utils:1.0</artifact>
  </jmeterExtensions>
  <!-- 设置jmeter生成结果文件格式-->
  <resultsFileFormat>xml</resultsFileFormat>
  <!-- 设置忽略失败是否停止运行-->
  <ignoreResultFailures>true</ignoreResultFailures>
  <!--设置结果是否有时间戳-->
  <testResultsTimestamp>false</testResultsTimestamp>
  <testFilesIncluded>
  <!-- //指定运行的jmeter脚本 -->
  <jMeterTestFile>testmaven1.jmx</jMeterTestFile>
  <jMeterTestFile>testmaven2.jmx</jMeterTestFile>
  <!--
  //使用正则表达式
  <jMeterTestFile>test*.jmx</jMeterTestFile>-->
  </testFilesIncluded>
  <!-- 指定jmx运行目录
  <testFilesDirectory>D:\workspaceN\maven2jmeter\src\test\jmeter\case1</testFilesDirectory>
  -->
  <!-- 指定jtl生成目录 -->
  <resultsDirectory>${jmeter.result.jtl.dir}</resultsDirectory>
  </configuration>
  <executions>
  <execution>
  <id>jmeter-tests</id>
  <phase>verify</phase>
  <!--脚本所在的文件夹 -->
  <goals>
  <goal>jmeter</goal>
  </goals>
  </execution>
  </executions>
  </plugin>
  <plugin>
  <!--根据xsl模版把jtl文件转换成html,官网地址: http://www.mojohaus.org/xml-maven-plugin/examples/transform-saxon.html-->
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <version>1.0-beta-3</version>
  <executions>
  <execution>
  <phase>verify</phase>
  <goals>
  <goal>transform</goal>
  </goals>
  </execution>
  </executions>
  <configuration>
  <transformationSets>
  <!-- 可以根据不同的模版,同事生成多个报告
  <transformationSet>
  <dir>${jmeter.result.jtl.dir}</dir>
  <stylesheet>src\test\resources\jmeter.results.shanhe.me.xsl</stylesheet>
  <outputDir>${jmeter.result.html.dir}</outputDir>
  <fileMappers>
  <fileMapper
  implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
  <targetExtension>html</targetExtension>
  </fileMapper>
  </fileMappers>
  </transformationSet> -->
  <transformationSet>
  <dir>${jmeter.result.jtl.dir}</dir>
  <stylesheet>src\test\resources\jmeter.results.shanhe.me.xsl</stylesheet>
  <outputDir>${jmeter.result.html.dir}</outputDir>
  <!-- 把jtl格式转传承html -->
  <fileMappers>
  <fileMapper
  implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
  <targetExtension>html</targetExtension>
  </fileMapper>
  </fileMappers>
  </transformationSet>
  </transformationSets>
  </configuration>
  <!-- using XSLT 2.0 -->
  <dependencies>
  <dependency>
  <groupId>net.sf.saxon</groupId>
  <artifactId>saxon</artifactId>
  <version>8.7</version>
  </dependency>
  </dependencies>
  </plugin>
  </plugins>
  </build>
  
</project>
页: [1]
查看完整版本: maven+jmeter+jenkins集成