maven jmeter jenkins idea

IDEA部分


直接创建maven工程

把这些文件放在src/test/jmeter目录下

脚本.jmx

jmeter.properties

saveservice.properties

system.properties

upgrade.properties

user.properties

工程下的resources文件放如下

jmeter.results.shanhe.me.xsl

jmeter-results-detail-report.xsl

jmeter-results-detail-report_21.xsl

jmeter-results-report.xsl

jmeter-results-report_21.xsl

二:下面的POM.XML,非常重要

<?xml version="1.0" encoding="utf-8"?>
<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>
    <artifactId>mainsoa-test</artifactId>
    <groupId>com.tester</groupId>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <description>Executes a JMeter test. Invoke with "mvn verify"</description>
    <properties>
        <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
    </properties>
    <dependencies>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.11.0</version>
        </dependency>

        <dependency>
            <groupId>com.hope.cloud</groupId>
            <artifactId>cloud</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${basedir}/lib/ext/amqp-client-3.6.1.jar</systemPath>
        </dependency>
               <!--调用第三方包-->
        <dependency>
            <groupId>com.hope.cloudb</groupId>
            <artifactId>cloudb</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${basedir}/lib/ext/jmeter-rabbit-amqp-plugin-1.0.jar</systemPath>
        </dependency>

    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/test</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <!-- 核心插件,用来执行jmx脚本,2.3对应jmeter的3.3版本  注意 -->
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.3.0</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                        <configuration>
                            <!-- 设置jmeter生成结果文件格式-->
                            <resultsFileFormat>xml</resultsFileFormat>
                            <!-- 设置忽略失败是否停止运行-->
                            <ignoreResultFailures>true</ignoreResultFailures>
                            <!--设置结果是否有时间戳-->
                            <testResultsTimestamp>false</testResultsTimestamp>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xml-maven-plugin</artifactId>
                <version>1.0.1</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>transform</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <transformationSets>
                        <transformationSet>
                            <dir>${project.build.directory}/jmeter/results</dir>
                            <stylesheet>src/test/resources/jmeter-results-report_21.xsl</stylesheet>
                            <outputDir>${project.build.directory}/jmeter/results</outputDir>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>html</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>
                    </transformationSets>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!-- here the phase you need -->
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/jmeter/lib</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>lib</directory>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <!-- in case we want to use a SNAPSHOT version of the jmeter-maven-plugin -->
    <pluginRepositories>
        <pluginRepository>
            <id>sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </pluginRepository>
    </pluginRepositories>
</project>

1.注意maven插件跟jmeter的版本

2,如果需要用到第三方JAR包,有如下2个办法

yi

<dependency>
<groupId>com.hope.cloud</groupId>  <!--自定义-->
<artifactId>cloud</artifactId>    <!--自定义-->
<version>1.0</version> <!--自定义-->
<scope>system</scope> <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
<systemPath>${basedir}/lib/ext/cloud.jar</systemPath> <!--项目根目录下的lib/ext文件夹下-->
</dependency> 

er

       将外部jar打入本地maven仓库
   cmd 进入jar包所在路径,执行以下命令
mvn install:install-file -Dfile=cloud.jar -DgroupId=com.hope.cloud -DartifactId=cloud -Dversion=1.0 -Dpackaging=jar
<dependency>
<groupId>com.hope.cloud</groupId>
<artifactId>cloud</artifactId>
<version>1.0</version>
</dependency>

三,jenkins


这个没什么太多好说的,直接上图,注意的是,需要jenkins 安装如下插件即可

HTML Publisher plugin 

构建后的操作,添加进去即可


如果需要发邮件的话,可以在构建后的操作添加



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值