首页 > 解决方案 > Jenkins & Newman:HTMLEXTRA 报告使用 Jenkins html 发布者在项目级别发布,仅用于成功的 Jenkins 构建

问题描述

我已经设置了一个Jenkins多分支管道Postman,使用Newman. 我用过的记者是-r cli,htmlextra,junit,junitfull

HTMLEXTRA报告确实使用Jenkins htmlpublisher项目级别发布,但是,仅适用于成功的 Jenkins 构建。换句话说,只有当所有 API 测试都通过时,才能HTMLEXTRA直接从项目菜单访问报告,如下面的屏幕截图所示。

项目级菜单

对于失败的构建,HTMLEXTRA虽然会创建报告,但我可以在菜单中为每个 Jenkins 运行打开它们,但不能在整个项目级别上打开它们。只有最新的成功构建报告被链接。

我的POSTACTIONSJenkins 阶段如下所示:

post {
        always {
            archiveArtifacts artifacts: 'build/report.html', fingerprint: true

             publishHTML (target: [ //DOCUMENTATION can be found here: https://plugins.jenkins.io/htmlpublisher/
                  allowMissing: false, //If checked, will allow report to be missing and build will not fail on missing report.
                  alwaysLinkToLastBuild: true, //If this control and "Keep past HTML reports" are checked, publish the link on project level even if build failed.
                  keepAll: true, //If checked, archive reports for all successful builds, otherwise only the most recent.
                  reportDir: 'build', //The path to the HTML report directory relative to the workspace.
                  reportFiles: 'report.html', //The file(s) to provide links inside the report directory.
                  reportName: 'Newman Test Report'
              ])

              junit "build/report-full.xml"
        }
    }

我的理解是 ifalwaysLinkToLastBuildkeepAllare both ,即使构建失败true,最新报告的链接也会在项目级别发布。HTMLEXTRA请参阅此处的官方文档https://plugins.jenkins.io/htmlpublisher

即使对于失败的 Jenkins 构建,您能帮我发布HTMLEXTRA项目级别的报告吗?非常感谢!

标签: jenkinsjenkins-pipelinepostmannewman

解决方案


推荐阅读