2

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 screenshot.

Any ideas?

Many thanks in advance, Christian

Michael Kemmerzell
  • 4,802
  • 4
  • 27
  • 43
Christian Baumann
  • 3,188
  • 3
  • 20
  • 37

1 Answers1

1

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:

  1. You create the file in the regular workspace of Jenkins

  2. The HTML Publisher Plugin aims to the correct folder

  3. 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.

Michael Kemmerzell
  • 4,802
  • 4
  • 27
  • 43
  • I am facing same issue -- "C:/Users/user/AppData/Roaming/npm/newman" run "C:/postmancollections/07072021/Test-Collection.postman_collection.json" -r cli,htmlextra --disable-unicode --reporter-htmlextra-export einvoice-test-suite-report.html --reporter-htmlextra-title "Report Test Summary" and my workspace location is C:\CustomWorkspace and I am able to see html report generated at that location but when I am accessing through jenkins then its empty just same as above – simond Jul 07 '21 at 15:39
  • Michael Kemmerzell , could you please help me with above – simond Jul 07 '21 at 15:42
  • I suggest opening up a new question, not sure if your problem fits to this question – Michael Kemmerzell Jul 07 '21 at 19:32
  • Michael Kemmerzell, added new question - https://stackoverflow.com/questions/68295598/newman-reporter-htmlextra-reports-with-jenkins-html-publisher-not-showing-report – simond Jul 08 '21 at 04:22