4

I have a .jmx file and I run it in NON-GUI mode on my local machine.

I'd like to push my project to Github and run it via pipeline from Jenkins.

How can I do that?

  1. Do I need to push the whole JMeter folder to Github in order to have the ability to run my JMeter test from Jenkins?
  2. What do I need to specify in the pipeline script?
1
  • 3
    You will get better answers on SO--nothing about this is testing-specific even though JMeter is a testing tool.
    – c32hedge
    Commented Apr 30, 2018 at 17:05

1 Answer 1

8

You will need 3 things in order to run JMeter test in Jenkins:

  1. JMeter .jmx script itself
  2. Java Runtime
  3. JMeter

If you have JMeter installed on the machine the minimal pipeline would look like:

pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps {
                git branch: 'your_branch', credentialsId: 'your_credentials', url: 'your_git_url'

            }
        }
    }
    stage('Run JMeter Test') {
        steps {
            dir('your_project_folder') {
                sh '/path/to/jmeter -n -t test.jmx -l result.jtl'
            }
        }
    }
}

Mind that sh is applicable for Linux/Unix/MacOSX systems, if your Jenkins master or slave is running Windows - change it to bat

See How to Run a JMeter Test with Jenkins 2.0 Pipelines and GitHub article for detailed setup instructions if needed.

Couple more useful links:

  • You might want to use JMeter Maven plugin in order to get automatic dependencies management, the chance that you have Maven installed in Jenkins is much higher than JMeter and Maven can download and configure JMeter automatically
  • You might also want to use Jenkins Performance Plugin which can publish test results and performance trends reports to your build dashboard.
3
  • thanks for your reply. What should I put on stage('Run JMeter Test') in the pipeline script in the case when my project isn't on local but is on Git? Commented May 1, 2018 at 10:59
  • Stage Checkout will pull your project from Git into Jenkins workspace
    – Dmitri T
    Commented May 1, 2018 at 14:54
  • @KonstantinV this is fairly basic stuff, you should probably best start by learning the basics of Jenkins. There's another option (that I haven't tried) using the performance-plugin
    – Rsf
    Commented Jan 9, 2020 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.