Nothing Special   »   [go: up one dir, main page]

Jmeter Integration With Jenkins and Maven Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1) Install Maven

Download Maven and set the path in environmental variables and verify with

mvn --version
2) Create a simple maven project
Use the quick start archetype:

mvn archetype:generate -DgroupId=com.example -DartifactId=projectname -


DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
3) Directory structure should be as follows
Main folder → src → test → jmeter → file.jmx
→ pom.xml
4) Add the Jmeter Maven Plugin
Edit the pom.xml. Remove the junit dependency and add jmeter plugin. It should
look like this:

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter-demo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jmeter-demo</name>
<url>http://maven.apache.org</url>

<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
5) Create a Jmeter Test and place the jmx file inside jmeter folder
6) Run it in Maven
Go to the project path and run the below command:

mvn install
7) Commit the Maven project to github
Create a repository in your github
Go to directory from command prompt
Do the following
→ $ git init
→ $ git add .
→ $ git commit -m 'First-commit'
Copy the link from your repository
→ $ git remote add origin <remote-repo-link>
→ $ git remote -v
→ $ git push origin master
8) Get Jenkins Running
Running a Jenkins instance locally is very easy. Download the latest Jenkins war
and then run the below command.

java -jar jenkins.war


9) Add the Performance Plugins
Go to Manage Jenkins → Manage Plugins → Available and add the following
plugins:
→Maven Integration plugin
→Git plugin
→GitHub plugin
→Performance plugin

10) Add Paths in Jenkins


Go to Manage Jenkins → Configure System and add paths of JDK, Maven and Git in
Jenkins.
11) Create the job in Jenkins
→Go to the Jenkins main page.
→Click New Job.
→Give the job a name.
→Choose free-style software project.
→Click OK
→Select Git under source code management
→Set the repository URL to <remote-repo-link>
→Add a Maven build step with “verify” as the goal.
→Down in Post-build Actions check the Publish Performance test result report
checkbox.
→Click the Add a new report box and choose JMeter.
→For Report files specify **/*.jtl
→Also under Post-build Actions check the Archive the artifacts checkbox.
→Under Files to archive specify **/*jtl-report.html. This will keep a copy of the html
formatted reports for each build so you can look at them in Jenkins.
→Click Save
→Click Build Now

12) Verify the reports

You might also like