【问题标题】:What is the relationship between the Jenkins "Cobertura" and " Code Coverage API" Plugin?Jenkins“Cobertura”和“Code Coverage API”插件之间有什么关系?
【发布时间】:2022-07-02 21:39:11
【问题描述】:

https://www.jenkins.io/doc/pipeline/steps/code-coverage-api/ 提到了 Cobertura XML 的两个不同适配器,“cobertura”和“coberturaAdapter”。

这两者有什么区别?其中一个是否依赖于“Cobertura”插件而另一个不依赖?我应该使用哪一个?

通过反复试验,我发现当安装了两个插件时,这在 Jenkinsfile 中有效:

publishCoverage adapters: [cobertura(coberturaReportFile: 'coverage.xml')], tag: 't'

请注意,coberturaReportFile 不是上述管道语法中描述的参数。两个适配器都提到了path。我在搜索使用path 时出现错误异常的类的Java 文档时找到了coberturaReportFile。结果是一个带有源代码渲染的“覆盖率报告”的 UI。

这似乎受到“Cobertura”插件的影响,因为当我尝试不使用它时,我发现我必须使用不同的调用:

publishCoverage adapters: [cobertura(path: 'coverage.xml')], tag: 't'

UI 也有所不同,而且(令我惊讶的是)看起来就像我安装了“Cobertura”的那个(没有源代码,用方框图代替表格)。

【问题讨论】:

  • 如果有人想知道:我使用 tag: ‘t’ 是因为我想合并两个由不同工作人员生成的报告 (plugins.jenkins.io/code-coverage-api/…)。这目前不起作用:我的 Jenkins 工作 PR 显示 两个 覆盖报告链接指向相同的 URL,并且内容似乎仅来自一名工作人员(第二个工作人员没有覆盖信息)。

标签: jenkins cobertura


【解决方案1】:

Cobertura 插件目前 depends on 代码覆盖 API 插件,自 jenkinsci/cobertura-plugin#101 (2018) 以来,并提供 CoberturaReportAdapteruses both coberturacoberturaAdapter 描述符。但是,Cobertura 插件要旧得多(首次标记于 2007 年);自己的cobertura step的API可以看here

代码覆盖率 API提供了一个 CoberturaReportAdapteronly uses cobertura 描述符。

因此,如果您使用 publishCoverage(来自 Code Coverage API),则根本不需要安装 Cobertura 插件(如您所见),但您需要使用 cobertura 适配器为了处理这种格式。

【讨论】:

    猜你喜欢
    • 2013-02-03
    • 2014-11-24
    • 1970-01-01
    • 2013-04-12
    • 1970-01-01
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    • 2013-10-30
    相关资源
    最近更新 更多