我如何在詹金斯生成HTML报告

时间:2018-10-06 19:21:05

标签: jenkins jenkins-plugins jenkins-pipeline jenkins-cli

Image of post build action step for "Publish HTML Reports plugin" in maven based project

添加插件后,我也收到http 404错误。

是否需要编写任何Shell脚本或管道中的任何代码来生成html报告,或者直接我们可以生成html报告?

您能帮我解决错误吗?... ??

3 个答案:

答案 0 :(得分:0)

根据documents on the plugin page,它只能帮助我们将页面带到Jenkins仪表板(而不生成页面)。这意味着我们必须在管道中生成HTML文件或使用其他工具来构建步骤。

如果您使用Maven,建议您查看Surefire。运行测试并在构建步骤中生成HTML报告。然后,在构建后的步骤中使用插件将它们发布。

答案 1 :(得分:0)

对于Freestyle项目:-

enter image description here

对于管道项目:-

添加以下代码:

publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: "HTML Report Directory", reportFiles: 'html-file_name', reportName: 'HTML Report', reportTitles: ''])

更改标签-相应地更改 reportDir和reportFiles

答案 2 :(得分:0)

因此,在我的项目中,首先我创建一个在本地运行测试期间创建的报告(为此使用 ExtentHtmlReporter 库)

  1. 在我的Jenkins中=>配置
  2. 下到“构建后操作”
  3. 按“添加构建后操作”
  4. 按“发布HTML报告”

添加的图片

enter image description here

在添加的字段中,您应该这样填写 path,html文件名(将其添加到我创建报告的项目中的图像) enter image description here