Reputation: 3434
I am running newman with newman-reporter-htmlextra in a Jenkins pipeline
, generating a html report which I want to publish via the jenkins html publisher.
This is the stage in the pipeline I´m using
stage('Newman tests') {
steps() {
script {
dir("${JENKINS_HOME}/workspace/myproject") {
sh 'newman run "./Collections/my_collection.postman_collection.json" --reporters cli,junit,htmlextra --reporter-junit-export "newman_result.xml" --reporter-htmlextra-export "newman_result.html"'
junit "*.xml"
}
}
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: '.',
reportFiles: 'newman_result.html',
reportName: 'Newman HTML Reporter'
]
}
This is running, and creating an entry Newman HTML Reporter
in my Jenkins
project.
However, when I open such a report, it is empty, pls check .
Any ideas?
Many thanks in advance, Christian
Upvotes: 2
Views: 6409
Reputation: 5256
I guess you are accessing the wrong folder when you want to publish your html result. You are creating your file not in the regular jenkins workspace:
dir("${JENKINS_HOME}/workspace/myproject") {
sh 'newman run "./Collections/my_collection.postman_collection.json" --reporters cli,junit,htmlextra --reporter-junit-export "newman_result.xml" --reporter-htmlextra-export "newman_result.html"'
junit "*.xml"
}
After you are leaving the script{}
you are accessing the original workspace of Jenkins so reportDir: '.'
is not the same folder where your file is which means no file = no html can be displayed.
You have 3 choices here:
You create the file in the regular workspace of Jenkins
The HTML Publisher Plugin aims to the correct folder
Put the HTML Publisher plugin into the scope of your dir{}
as you did with your junit plugin
To find out easily which folder you are accessing in which scope you can run an echo pwd
. Do this once in the scope of your dir{}
and once in the scope of your plugin then it should be clear that the reportDir
of your plugin is wrong.
Upvotes: 1