You will need 3 things in order to run JMeter test in Jenkins:
- JMeter .jmx script itself
- Java Runtime
- 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.