Jenkins Build Failure, Cobertura Error
Asked Answered
S

2

9

I tried to build a job and it returns following error:

> 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]

Any idea how to resolve it?

Sharecrop answered 8/8, 2018 at 19:6 Comment(0)
S
3

I guess the jdk in question was above 8 which is still not supported by Cobertura: https://github.com/mojohaus/cobertura-maven-plugin/issues/30

[ERROR] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (verification) on project generex: Execution verification 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 /usr/local/lib/jvm/openjdk11/../lib/tools.jar

I had to switch to https://www.jacoco.org/jacoco/ instead.

Shortwinded answered 2/7, 2019 at 12:44 Comment(1)
how to switch to jacoco: github.com/trautonen/coveralls-maven-plugin#jacocoVirga
P
2

Seems like you are missing the tools jar in your JDK/JRE library you can confirm it by searching for the JAR in the lib folder if it's not present then you can add the following in your 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>

Where ${env.JAVA_HOME} points to the JAVA you set in environment variables if you are using another JRE apart from the one set then specify the path like so /var/lib/jenkins/tools/hudson.model.JDK/myjava/JDK8/lib/lib

Hope it helps :)

Platitudinize answered 9/8, 2018 at 3:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.