It's straightforward to set hardcoded values in the plugin's Advanced > Presentation > Classifications section, but a value like ${FOO}
is displayed literally as ${FOO} instead of expanding.
I set FOO like so in the build shell script, but it does not get displayed in the report.
export FOO=hello
I then tried creating my own .properties file:
echo buildVersion=$LAST_BUILD_VERSION >> report-vars.properties
echo greeting=hola >> report-vars.properties
echo classifications.message=hello >> report-vars.properties
cat report-vars.properties
find . -name '*\.properties'
In Console Output below, I can confirm the Cucumber report plugin is finding the .properties file:
[CucumberReport] Copied 2 properties files from workspace
Based on the find
output above, the two files must be
Since those are the only .properties files present.
I have token-macro:2.6
installed.
We can specify custom classifications by using a pipeline. Create a new Jenkins Pipeline (New Item > Pipeline) and convert your existing job.
A general pipeline may take the following form
node {
stage('checkout') {
git ...
}
stage('build') {
withCredentials(...) {
sh '''
...
cat << EOF > dynamic.properties
dynamicVar=$(curl ...)
EOF
'''
}
}
stage('post-build') {
def jenkins_home = manager.getEnvVariable('JENKINS_HOME')
...
def prop_dir = ...
def report_file = "${prop_dir}/dynamic.properties"
def contents = readFile("${report_file}").split('\n')
def dynamicVal = contents[0].split("=")[1]
cucumber fileIncludePattern: '**/*.json',
fileExcludePattern: '',
jsonReportDirectory: '',
failedStepsNumber: '0',
skippedStepsNumber: '0',
pendingStepsNumber: '0',
undefinedStepsNumber: '0',
failedScenariosNumber: '0',
failedFeaturesNumber: '0',
sortingMethod: 'ALPHABETICAL',
trendsLimit: 10,
classifications: [
[
'key': 'One such dynamic var',
'value': "${dynamicVal}"
]
]
}
}
New to pipelines? Click "Pipeline syntax" link in the left sidebar of a finished job. There are plenty of examples in the Snippet Generator.