Jenkins 未生成采摘报告

Jenkins not picking report generated

我已经在 J​​enkins 中为 运行 我在 centOS7.6 上通过 Newman 收集的邮递员创建了管道。收集成功 运行 但在创建报告阶段失败并出现以下错误 -- 错误:未找到测试报告文件。配置错误? 已完成:失败*

你能帮忙解决问题吗?

管道:

    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'
                    }
                }
            }
   }

您需要提供reportdir中的目录,如下图:

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'
                    }

请使用 jaiman 进行 jenkins 和邮件集成。当您在 jenkins 中集成并行执行时,这非常有用。

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