JaCoCo 报告在 Jenkins 中失败:java.lang.ArrayIndexOutOfBoundsException
JaCoCo report fails in Jenkins: java.lang.ArrayIndexOutOfBoundsException
我一直在本地使用 JaCoCo 没有问题。
当 运行 远程服务器上的 Jenkins 作业时,该作业构建良好并生成 JaCoCo 覆盖率报告(即它出现在我的 workspace/report
文件夹中)但是在尝试发布时构建失败关于詹金斯的报告。
我正在使用 Jenkins 1.460 和 JaCoCo 5.0.0。
我已经为 Jenkins 配置了:
- 可执行文件的路径:
**/**.exec
- classes 的路径:
**/dist/validation/WEB-INF/classes
- 源路径:
**/src
(我也尝试过 **/Validation/src
,并明确包含 **/**.class
并排除其他文件类型)
这是配置问题还是兼容性错误?
[编辑:如果它能帮助其他人,其他论坛说 JaCoCo 需要 ASM 5.+ 来管理 Java 8 class 分析。我已经在使用 ASM 5.0.1。]
BUILD SUCCESSFUL
Total time: 4 minutes 57 seconds
Archiving artifacts
Recording test results
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] **/**.exec;**/dist/validation/WEB-INF/classes;**/Validation/src; locations are configured
[JaCoCo plugin] Number of found exec files for pattern **/**.exec: 1
[JaCoCo plugin] Saving matched execfiles: E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\jacoco.exec
[JaCoCo plugin] Saving matched class directories for class-pattern: **/dist/validation/WEB-INF/classes: E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\dist\validation\WEB-INF\classes
[JaCoCo plugin] Saving matched source directories for source-pattern: **/Validation/src: E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\src
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: []
[JaCoCo plugin] exclusions: []
ERROR: Publisher hudson.plugins.jacoco.JacocoPublisher aborted due to exception
java.io.IOException: Error while analyzing class E:\Jenkins\jobs\Validation - Test Cases\builds15-02-23_15-59-44\jacoco\classes\org\gosh\validation\filters\ModifiedFileListFilter.class.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:150)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:144)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:175)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:208)
at hudson.plugins.jacoco.ExecutionFileLoader.analyzeStructure(ExecutionFileLoader.java:126)
at hudson.plugins.jacoco.ExecutionFileLoader.loadBundleCoverage(ExecutionFileLoader.java:133)
at hudson.plugins.jacoco.JacocoReportDir.parse(JacocoReportDir.java:102)
at hudson.plugins.jacoco.JacocoBuildAction.loadRatios(JacocoBuildAction.java:291)
at hudson.plugins.jacoco.JacocoBuildAction.load(JacocoBuildAction.java:273)
at hudson.plugins.jacoco.JacocoPublisher.perform(JacocoPublisher.java:371)
at hudson.tasks.BuildStepMonitor.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:705)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:680)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:658)
at hudson.model.Build$RunnerImpl.post2(Build.java:162)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:627)
at hudson.model.Run.run(Run.java:1446)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 7
at org.jacoco.core.internal.analysis.MethodAnalyzer.addProbe(MethodAnalyzer.java:288)
at org.jacoco.core.internal.analysis.MethodAnalyzer.visitInsnWithProbe(MethodAnalyzer.java:224)
at org.jacoco.core.internal.flow.MethodProbesAdapter.visitInsn(MethodProbesAdapter.java:76)
at org.objectweb.asm.tree.InsnNode.accept(InsnNode.java:80)
at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162)
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:815)
at org.jacoco.core.internal.flow.ClassProbesAdapter.visitEnd(ClassProbesAdapter.java:124)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:107)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:142)
... 18 more
Finished: FAILURE
[更新 - 解决方案]
使用 I installed the recently released JaCoCo-0.7.4 (see eclemma.org/jacoco) on my local drive. This version contains the fix for issue 27088。我还必须删除并重新安装 Jenkins JaCoCo 插件(我使用的是 Jenkins 插件管理器)。
两件事:
在 JaCoCo Post-build 操作的 Jenkins 项目配置中,确保设置了 Inclusions 字段。 */*.class 之类的东西应该可以工作。还要从上面的表达式中删除第二个星号 (*)。将它们设为 */*.exec、*/dist/ 等
我今天从 Jacoco 插件中遇到了类似的 ArrayIndexOutOfBounds 异常,但它只发生在 Jenkins 中,而不是 运行 从命令行构建 maven 时。谷歌搜索表明 Jacoco 插件包含和排除字段语法会导致人们出现问题。我为这些字段尝试了几种不同的格式但无济于事,所以我转向使用起来很方便的 cobertura 插件:https://wiki.jenkins-ci.org/display/JENKINS/Cobertura+Plugin#CoberturaPlugin-ConfiguringtheCoberturaPlugin
构建期间使用的 JaCoCo 版本与 Jenkins 在 post-build 操作中使用的版本之间似乎存在兼容性问题。
maven-jacoco-plugin 版本 0.7.3.201502191951
与 Jenkins JaCoCo 插件版本 1.0.18
结合导致了这个问题。 maven-jacoco-plugin 的版本 0.7.2.201409121644
似乎是兼容的。
另见 https://issues.jenkins-ci.org/browse/JENKINS-27088 and https://github.com/jenkinsci/jacoco-plugin/pull/51
我一直在本地使用 JaCoCo 没有问题。
当 运行 远程服务器上的 Jenkins 作业时,该作业构建良好并生成 JaCoCo 覆盖率报告(即它出现在我的 workspace/report
文件夹中)但是在尝试发布时构建失败关于詹金斯的报告。
我正在使用 Jenkins 1.460 和 JaCoCo 5.0.0。
我已经为 Jenkins 配置了:
- 可执行文件的路径:
**/**.exec
- classes 的路径:
**/dist/validation/WEB-INF/classes
- 源路径:
**/src
(我也尝试过**/Validation/src
,并明确包含**/**.class
并排除其他文件类型)
这是配置问题还是兼容性错误?
[编辑:如果它能帮助其他人,其他论坛说 JaCoCo 需要 ASM 5.+ 来管理 Java 8 class 分析。我已经在使用 ASM 5.0.1。]
BUILD SUCCESSFUL
Total time: 4 minutes 57 seconds
Archiving artifacts
Recording test results
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] **/**.exec;**/dist/validation/WEB-INF/classes;**/Validation/src; locations are configured
[JaCoCo plugin] Number of found exec files for pattern **/**.exec: 1
[JaCoCo plugin] Saving matched execfiles: E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\jacoco.exec
[JaCoCo plugin] Saving matched class directories for class-pattern: **/dist/validation/WEB-INF/classes: E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\dist\validation\WEB-INF\classes
[JaCoCo plugin] Saving matched source directories for source-pattern: **/Validation/src: E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\src
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: []
[JaCoCo plugin] exclusions: []
ERROR: Publisher hudson.plugins.jacoco.JacocoPublisher aborted due to exception
java.io.IOException: Error while analyzing class E:\Jenkins\jobs\Validation - Test Cases\builds15-02-23_15-59-44\jacoco\classes\org\gosh\validation\filters\ModifiedFileListFilter.class.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:150)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:144)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:175)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:208)
at hudson.plugins.jacoco.ExecutionFileLoader.analyzeStructure(ExecutionFileLoader.java:126)
at hudson.plugins.jacoco.ExecutionFileLoader.loadBundleCoverage(ExecutionFileLoader.java:133)
at hudson.plugins.jacoco.JacocoReportDir.parse(JacocoReportDir.java:102)
at hudson.plugins.jacoco.JacocoBuildAction.loadRatios(JacocoBuildAction.java:291)
at hudson.plugins.jacoco.JacocoBuildAction.load(JacocoBuildAction.java:273)
at hudson.plugins.jacoco.JacocoPublisher.perform(JacocoPublisher.java:371)
at hudson.tasks.BuildStepMonitor.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:705)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:680)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:658)
at hudson.model.Build$RunnerImpl.post2(Build.java:162)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:627)
at hudson.model.Run.run(Run.java:1446)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 7
at org.jacoco.core.internal.analysis.MethodAnalyzer.addProbe(MethodAnalyzer.java:288)
at org.jacoco.core.internal.analysis.MethodAnalyzer.visitInsnWithProbe(MethodAnalyzer.java:224)
at org.jacoco.core.internal.flow.MethodProbesAdapter.visitInsn(MethodProbesAdapter.java:76)
at org.objectweb.asm.tree.InsnNode.accept(InsnNode.java:80)
at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162)
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:815)
at org.jacoco.core.internal.flow.ClassProbesAdapter.visitEnd(ClassProbesAdapter.java:124)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:107)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:142)
... 18 more
Finished: FAILURE
[更新 - 解决方案]
使用
两件事: 在 JaCoCo Post-build 操作的 Jenkins 项目配置中,确保设置了 Inclusions 字段。 */*.class 之类的东西应该可以工作。还要从上面的表达式中删除第二个星号 (*)。将它们设为 */*.exec、*/dist/ 等
我今天从 Jacoco 插件中遇到了类似的 ArrayIndexOutOfBounds 异常,但它只发生在 Jenkins 中,而不是 运行 从命令行构建 maven 时。谷歌搜索表明 Jacoco 插件包含和排除字段语法会导致人们出现问题。我为这些字段尝试了几种不同的格式但无济于事,所以我转向使用起来很方便的 cobertura 插件:https://wiki.jenkins-ci.org/display/JENKINS/Cobertura+Plugin#CoberturaPlugin-ConfiguringtheCoberturaPlugin
构建期间使用的 JaCoCo 版本与 Jenkins 在 post-build 操作中使用的版本之间似乎存在兼容性问题。
maven-jacoco-plugin 版本 0.7.3.201502191951
与 Jenkins JaCoCo 插件版本 1.0.18
结合导致了这个问题。 maven-jacoco-plugin 的版本 0.7.2.201409121644
似乎是兼容的。
另见 https://issues.jenkins-ci.org/browse/JENKINS-27088 and https://github.com/jenkinsci/jacoco-plugin/pull/51