verbatim
verbatim

Reputation: 11

jmeter test using Jenkins

Goal: jmeter test run on Jenkins.

I've created a script in Jmeter.

I've downloaded jmeter-maven-plugin.

I've created the jmeter directory (where I've put my script) in jmeter-maven-plugin/scr/testwhere directory.

I don't know what to do next.

Upvotes: 0

Views: 1652

Answers (3)

ViktorK
ViktorK

Reputation: 1

Yo can add "Execute Shell" build step for your Jenkins project with shell commands to run you JMeter Test Plan without UI. Something like this:

sh $jmeterdir/jmeter.sh -t $jmeterdir/HealthCheck.jmx  -n -j jmeter.log

In order to check results of JMeter Test Plan executing for making a decision about Build Failure/Success you can implement the following approach:
1. Add Simple Data Writer to your Test Plan and make it log errors only into some file
2. Create sh script which takes you error log as parameter and check number of lines in it. If number of lines not equal to 1 - it means that we have at least one error in error log - do "exit 1" - this fails build:

count=$(wc -l < BuildErrors.csv)
if test $count != "1" 
 then 
  echo "There are errors during test."
  exit 1 


3. Run this script from Jenkins "Execute Shell" build step

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168002

There is a Jenkins Performance Plugin which provides better integration with Jenkins than Maven does.

However if you need to stick to Maven or don't have possibility to install the plugin see 5 Ways To Launch a JMeter Test without Using the JMeter GUI for Maven, Ant, command-line and Java instructions of kicking off a JMeter test.

Upvotes: 0

ben75
ben75

Reputation: 28706

from the doc :

Add the plugin to the build section of your pom's project :

<plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>1.9.1</version>
    <executions>
        <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
                <goal>jmeter</goal>
            </goals>
       </execution>
    </executions>
</plugin>

Then you can create a new jenkins job on your project and run the jmeter tests by definig this command in the job configuration:

mvn verify

Upvotes: 3

Related Questions