Jenkins 构建失败,Cobertura 错误

Aar*_*oni 6 build cobertura jenkins

我试图建立一个工作,它返回以下错误:

> 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]
Run Code Online (Sandbox Code Playgroud)

知道如何解决吗?

roh*_*mas 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>
Run Code Online (Sandbox Code Playgroud)

其中 ${env.JAVA_HOME} 指向您在环境变量中设置的 JAVA(如果您使用的是一组 JRE 之外的另一个 JRE),则像这样指定路径/var/lib/jenkins/tools/hudson.model.JDK/myjava/JDK8/lib/lib

希望能帮助到你 :)