Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Build Failure, Cobertura Error

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?

like image 492
Aarit Soni Avatar asked Aug 08 '18 19:08

Aarit Soni


People also ask

How to control the number of continuous failure builds in Jenkins?

So, let’s use fixed period; and set it to 180 (3 minutes). This is used to control the number of continuous failure builds. Jenkins will not automatically retry more than this maximum number of consecutive failures. So, let’s set 2, so that it is retried only two times. 11. Now, run the build and see it executing two times after the failure.

How to manage Jenkins plugins in Jenkins?

Click the ‘Manage Jenkins’ menu displayed on the right side of the screen. You will be redirected to the ‘Manage Jenkins’ page, where you need to select the ‘Manage Plugins’ option. 3. Click on ‘Available’ once you are at ‘Manage Plugins’ page.

How do I stop Jenkins from crashing when trying to install?

The simplest way around this issue is to run your Jenkins as a service with elevated privileges. The way to do this is outlined in this question. On a different note, I'm not completely sure what is happening here but assuming that you are trying to install JDK.

Was Cobertura report generation successful?

[INFO] Cobertura Report generation was successful. [Cobertura] Publishing Cobertura coverage report... [Cobertura] No coverage results were found using the pattern '' relative to '/var/lib/jenkins/workspace/junittests'. Did you enter a pattern relative to the correct directory?


2 Answers

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.

like image 79
Vadzim Avatar answered Nov 09 '22 13:11

Vadzim


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 :)

like image 24
rohit thomas Avatar answered Nov 09 '22 12:11

rohit thomas