Jenkins not picking report generated

507 views Asked by At

I have created pipeline in Jenkins for running my postman collection via Newman on centOS7.6. collection is running successfully but failing at stage of creating a report with below error -- ERROR: No test report files were found. Configuration error? Finished: FAILURE*

Could you help in resolving the problem?

pipeline:

    currentBuild.displayName="Prod-API-AUtomation-#"+currentBuild.number
    pipeline{
            agent any
            tools {nodejs "NodeJS"}
            stages{
                stage("Building"){
                    steps{
                        sh 'npm install -g newman'
                        sh 'npm install -g newman-reporter-htmlextra'
                    }
                }
                stage("Execute Collection"){
                    steps{
                        script{
                            try{
                                sh "newman run Test.postman_collection.json -e Test.postman_environment.json -r cli,junit,htmlextra --reporter-junit-export $WORKSPACE/newman/prod_report.xml --reporter-htmlextra-export $WORKSPACE/newman/prod_Report.html"
                                currentBuild.result="SUCCESS"
                            }catch(Exception ex){
                                currentBuild.result="FAILURE"
                            }
                        }
                    }
                }
                stage("Generating Report"){
                    steps{
                        publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, keepAll: false, reportDir: 'newman', reportFiles: '$WORKSPACE/newman', reportName: 'HTML Report', reportTitles: ''])
                        junit '$WORKSPACE/newman/prod_report.xml'
                    }
                }
            }
   }
2

There are 2 answers

0
Altaf On BEST ANSWER

You need to provide the directory in the reportdir as shown below:

stage("Generating Report"){
                    steps{
                        publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, keepAll: false, reportDir: '$WORKSPACE/newman', reportFiles: 'prod_report.xml', reportName: 'HTML Report', reportTitles: ''])
                        junit '$WORKSPACE/newman/prod_report.xml'
                    }

1
Jayanth Bala On

Please use jaiman for jenkins and mailing integration. this is very useful when you are integrating for parallel execution in jenkins.

https://www.npmjs.com/package/jaiman