java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor when manually building the plugin

java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor when manually building the plugin

我正在尝试在 Jenkins (2.138.2) 中使用 JaCoCo 代码覆盖率插件 (3.0.4)。它按预期工作,但我不喜欢它的是,当构建失败或中止时,它不会生成报告。此代码在这里:https://github.com/jenkinsci/jacoco-plugin/blob/master/src/main/java/hudson/plugins/jacoco/JacocoPublisher.java#L585-L587

有一个 pull request 用于此,但看起来它在最初创建后没有得到处理。

因此我尝试通过后续步骤自行重建插件:

  1. 克隆https://github.com/jenkinsci/jacoco-plugin
  2. 查看最新版本 3.0.4
  3. 从上面的 JacocoPublisher 中删除 if 语句 class
  4. 构建插件(mvn package 正如他们所说)

我可以毫无问题地构建它。接下来的步骤是:

  1. 导航到 Jenkins -> 管理 Jenkins -> 管理插件 -> 高级
  2. 上传生成的jacoco.hpi文件并重启Jenkins

完成后,Post 生成 运行 JaCoCo 报告的步骤消失了,我在 jenkins 日志中看到了这一点:

06-Nov-2018 17:19:24.353 WARNING [Handling GET /jenkins/job/testing-jacoco-code-coverage-reports/configure from 0:0:0:0:0:0:0:1 : http-nio-8080-exec-3 Job/configure.jelly Project/configure-entries.jelly] hudson.ExpressionFactory2$JexlExpression.evaluate Caught exception evaluating: i.descriptor in /jenkins/job/testing-jacoco-code-coverage-reports/configure. Reason: java.lang.reflect.InvocationTargetException
 java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor
        at jenkins.model.Jenkins.getDescriptorOrDie(Jenkins.java:1517)
        at hudson.tasks.Publisher.getDescriptor(Publisher.java:122)
        at hudson.tasks.Recorder.getDescriptor(Recorder.java:51)
        at hudson.plugins.jacoco.JacocoPublisher.getDescriptor(JacocoPublisher.java:775)
        ... 168 more

Jenkins 提出的 solution for this issue 在这里不适用,因为插件已经扩展了所需的 classes。 恢复到以前的版本(3.0.4 但不是我的自定义版本)使构建步骤再次出现,但同样缺乏我需要的行为。

我错过了什么吗?

谢谢!

删除原始版本后,我还必须从 /plugins 文件夹中删除剩余的 jacoco 插件文件。之后,安装顺利。