Jenkins with JMeter report

Songxibin
2 min readJun 23, 2020

To show JMeter report in Devops

  1. Install Peformance Plugin in Jenkins

2. Edit the Jenkins Pipeline file. Define the Selection for whether to go for JMeter test choice.

3. Use script to conduct the JMeter script with output.

4. Convert the output to Report.

5. Published it to Jenkins.

stage(‘Proceed with Performance Testing’) {
steps {
script {
def USER_INPUT = input(
message: ‘Do you want to do the Performance Testing now?’,
parameters: [
[$class: ‘ChoiceParameterDefinition’,
choices: [‘no’,’yes’].join(‘\n’),
name: ‘input’,
description: ‘Menu — select box option’]
])

echo “The answer is: ${USER_INPUT}”

if( “${USER_INPUT}” == “yes”){
sh ‘’’mkdir -p report
jmeter -n -t /var/lib/jenkins/jmeter/project.jmx -l report.csv -o report
jmeter -g report.csv -o report’’’
} else {
//do something else
}
}

}
}

stage(‘Publish Report’) {
steps {
script {
publishHTML(target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: ‘report’,
reportFiles: ‘index.html’,
reportTitles: “JReport”,
reportName: “JReport”
])
}

}
}

After the script finished, we can find in Jenkins Project.

Click the JReport Icon, you will see the report.

If The report images can not be loaded, that is controlled by Jenkins Security Policy. you can reference to the following steps for solution.

In “Manage Jenkins”, “Script Console”

input the following and Run.

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src * 'unsafe-inline'; font-src *;img-src 'self' data: *;frame-ancestors 'self'")

--

--