Missing

Jmeter with Jenkins Example

Dec 02, 2020 by ohiodn8




In your jenkins freestyle project, go to configure and go to the "Build" steps.

/opt/jmeter-5.0/bin/jmeter.sh -n -t sample.jmx -l sample_results.jtl

In the "Post Build Actions", select "Publish Performance Test Result Report" and put the .jtl file.



Jenkins Pipeline Example

node(node1||node2) {
  stage('Jmeter Load Test') {
    sh "/opt/jmeter-5.0/bin/jmeter.sh -n -t sample.jmx -l sample_results.jtl"
  }
  stage('Jmeter Generate HTML') {
    sh "rm -rf /var/lib/jenkins/workspace/sample_job/dashboard/output/*"
    sh "/opt/jmeter-5.0/bin/jmeter.sh -g /var/lib/jenkins/workspace/sample_job/sample_results.jtl -o /var/lib/jenkins/workspace/sample_job/dashboard/output"
  }  
  stage('Performance Report') {
    perfReport 'sample_results.jtl'
  }  
}


Using Ant to run the test

ant -buildfile /opt/jmeter-5.0/extras/build.xml


Jenkins Pipeline with jmx generated from ruby-jmeter

node('sample-node') {
  stage('SCM') {
    git credentialsId: '896sampled-jenkins-git5-IDb', 
        url: 'https://gitserver.com/ruby-jmeter-sample.git' //using sampleFile.rb and .ruby-version files
  }    
  stage('Load RVM') {
    sh '''#!/bin/bash -xl
        echo $0
        ruby -v
        ruby sampleFile.rb
    '''    
  }  
  stage('Jmeter Load Test') {  
    sh "jmeter.sh -n -t sample_testplan.jmx -r -l sample.jtl" //using -r for remote_hosts from jmeter.properties
  }
  stage('Jmeter Generate HTML') {
    sh "/opt/jmeter-5.0/bin/jmeter.sh -g /var/lib/jenkins/workspace/sample_job/sample.jtl -o /var/lib/jenkins/workspace/sample_job/dashboard/output"
  }  
  stage('Performance Report') {
    perfReport 'sample.jtl'
  }  
}







About ohiodn8

Ruby on Rails developer, AWS Engineer, anything fun, music, a little bit of mobile game. . .

Comments