Jenkins构建失败,Cobertura错误。

9
我尝试构建一个作业,但返回以下错误:
> Failed to execute goal
> org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli)
> on project addressbook: Execution default-cli of goal
> org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed: Plugin
> org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its
> dependencies could not be resolved: Could not find artifact
> com.sun:tools:jar:0 at specified path
> /var/lib/jenkins/tools/hudson.model.JDK/myjava/../lib/tools.jar ->
> [Help 1]

有什么想法可以解决这个问题吗?
2个回答

3
我猜测所使用的jdk版本高于8,这是 Cobertura 还不支持的:https://github.com/mojohaus/cobertura-maven-plugin/issues/30

[错误] 无法执行目标 org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (verification), 在项目 generex 上执行验证目标 org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument 失败: 无法解析插件 org.codehaus.mojo:cobertura-maven-plugin:2.7 或其依赖项之一: 在指定路径 /usr/local/lib/jvm/openjdk11/../lib/tools.jar 中找不到 com.sun:tools:jar:0 的构件

我不得不转用 https://www.jacoco.org/jacoco/

1
如何切换到Jacoco: https://github.com/trautonen/coveralls-maven-plugin#jacoco - eis

2

看起来你的JDK/JRE库中缺少工具jar,你可以通过在lib文件夹中搜索JAR来确认。如果不存在,则可以在pom.xml中添加以下内容:

<dependency>
   <groupId>com.sun</groupId>
   <artifactId>tools</artifactId>
   <version>1.6.0</version>
   <scope>system</scope>
   <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
 </dependency>

${env.JAVA_HOME}指向您在环境变量中设置的JAVA路径。如果您使用另一个JRE,那么请按以下方式指定路径:/var/lib/jenkins/tools/hudson.model.JDK/myjava/JDK8/lib/lib

希望对您有所帮助 :)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接