How to get JaCoCo coverage with Sonar in Jenkins?

I followed the instructions here
I DO NOT use Maven.

The output of my work, Jenkins says: 12: 32: 33.951 INFO JaCoCoSensor sensor ... 12: 32: 33.961 INFO The project coverage was set to 0%, because JaCoCo execution data was not reset: / var / lib / jenkins / workspace / SeqGen / SeqGen / jacoco.exec 12: 32: 35.152 INFO JaCoCoSensor sensor completed: 1201 ms

Here are my properties:

project.home=SeqGen sonar.projectKey=com.skyboximaging:seqgen sonar.projectName="SeqGen" sonar.projectVersion=1.0 sonar.dynamicAnalysis=true sources=src/java tests=test/java binaries=classes sonar.jacoco.reportPath=jacoco.exec sonar.jacoco.antTargets=test-with-coverage 

On the sonar server, I installed General Settings> Code Coverage> Code Coverage Plugin for jacoco

I am very confused by the documentation at http://docs.codehaus.org/display/SONAR/Code+coverage+plugins I am particularly puzzled by this sentence: "During sonar analysis, the Sonar Jacoco plugin will take care of attaching the Jacoco agent to the JVM and to run unit tests "

As far as I can tell, my Ant target is not being called. How does the Sonar Jacoco plugin know where to find my build.xml?

What am I doing wrong?

+4
source share
3 answers
+5
source

Providing an answer to the next poor soul who spends hours trying to figure out why this is not working. Apparently this function has been removed:

Delete the "sonar.jacoco.antTargets" property and related classes in the plugin

+3
source

One possibility is that the name of your ant task for junit does not match the name specified in the properties.

You specified

 sonar.jacoco.antTargets=test-with-coverage 

According to the documentation there should be an ant target with exactly the same name. Also for this purpose junit should also be installed on fork.

+1
source

Source: https://habr.com/ru/post/1391551/


All Articles