是否可以在 Jenkins 仪表板上显示 Jacoco Coverage 报告?

Is it possible to display Jacoco Coverage report on Jenkins dashboard?

我有 jenkins 文件,它有 publishHTML 方法来生成带有 .html jacoco 结果文件的报告。是否可以像 'Test Trend Result' 这样在仪表板上显示该报告?

您需要使用 JaCoCo plugin

Get coverage data as part of your build First you need to get coverage calculated as part of your build/tests, see the JaCoCo documentation for details. You need at least one or more *.exec file available after tests are executed. Usually this means adjusting your Maven pom.xml or Ant build.xml file..

Set up coverage retrieval and publishing In order to get the coverage data published to Jenkins, you need to add a JaCoCo publisher and configure it so it will find all the necessary information. Use the help provided via the question-mark links for more information. Basically you specify where the *.exec files are, where compiled code can be found and where the corresponding source code is located after the build is finished to let the plugin gather all necessary pieces of information..

所以我经历了一番然后找到了直接添加到管道的解决方案

publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]

参考:https://github.com/jenkinsci/code-coverage-api-plugin