【问题标题】:Jenkins not picking report generated詹金斯没有选择报告生成
【发布时间】:2021-09-10 14:45:56
【问题描述】:

我在 Jenkins 中创建了管道,用于在 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'
                    }
                }
            }
   }

【问题讨论】:

  • publishHTMLreportDir 应该是'$WORKSPACE/newman'reportFiles 应该是'prod_report.xml' b>

标签: jenkins postman newman html-reports-jenkins


【解决方案1】:

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

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

【讨论】:

  • 你好@jayanth-bala。我用过你们的产品。但是无法将报告发送到我的 smtp 服务器,因为无法输入授权数据。您能否分享源代码来修复或修复此问题?还是以 newman 的身份发布到 github 上?
【解决方案2】:

您需要提供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'
                    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 2023-01-26
    相关资源
    最近更新 更多