2

I am trying to use Jenkins' Build Number in the naming of a Log that I would want to be saved as a post build action

Will the below format work

C:\Jenkins\workspace\Jmeter_Jenkins_Test_Job\Jenkins_Results\"${env.BUILD_NUMBER}"results.jtl

ganvartin
  • 35
  • 2
  • 9

2 Answers2

1

As per Building a software project wiki article the environment variable you're looking for is BUILD_NUMBER and in case of Windows operating system you can access it as:

%BUILD_NUMBER%

so if you want to amend JMeter result file name to include build number you can do something like:

jmeter -n -t /path/to/test.jmx -l /path/to/result-%BUILD_NUMBER%-.jtl

enter image description here

and in the runtime the variable will be evaluated to the current Jenkins build number:

enter image description here

More information just in case: Continuous Integration 101: How to Run JMeter With Jenkins

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
-1

Without having laid my hands on a Jenkins installation for quite some time:

Yes, you can do that and it has been done before!

You could do something like:

pipeline {
    agent any
    stages {
        stage('test') {
             sh 'path/to/jmeter.bat -n -t ${env.WORKSPACE}my_test.jmx -l my_test${env.BUILD_ID}_${env.BUILD_NUMBER}.jtl'
        }
    }
}

I would propose to create the HTML dashboard report first though and then publish that in Jenkins - you could use https://jenkins.io/doc/pipeline/steps/htmlpublisher/ to do that. Further you should avoid absolute paths in favor of using the WORKSPACE environment variable (see https://jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables for reference). If you need some general idea of how to run the test via Jenkins you could have a look at https://code-maven.com/jenkins-pipeline-running-external-programs and https://jmeter.apache.org/usermanual/get-started.html#non_gui

If you already tried to achieve something and need more specific help, please come forward with some more detail.

monhelm
  • 149
  • 6