Search code examples
mavenjenkinssonarqubeclover

Sonar not picking up clover test results created by running maven in jenkins


I've been working on this all day and haven't been able to find a solution, so thought i'd turn to the stackoverflow community.

I have a server setup with Jenkins (version 1.454). It's configured to perform the build with Maven (version 3.0.4). The build command is as follows:

clean clover2:setup verify clover2:aggregate clover2:clover

Jenkins has the sonar plugin installed and configured. My sonar install (version 3) is on a different server to jenkins. After the build is completed, i can see the results on sonar (the basics of the build).

I have installed to sonar the clover plugin (sonar-clover-plugin-2.8.jar) manually by putting it into the 'extentions/plugins' folder. It appeared in sonar and I can configure it. I put in the license, version (3.1.4) and sonar.clover.reportPath as "target\site\clover\clover.xml".

When I run the build, it is successful as before, and I can see the basic results as before in Sonar, however, I cannot see any test code coverage results. When I look at the maven build output I notice the following:

[INFO] Writing report to '/opt/jenkins/jobs/foo/workspace/target/site/clover/clover.xml'

and then near the bottom of the output:

[INFO] [15:08:36.586] Clover XML report not found

The following are also in my pom:

        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.clover.reportPath>target\site\clover\clover.xml</sonar.clover.reportPath>
    <sonar.surefire.reportsPath>target\surefire-reports</sonar.surefire.reportsPath>
    <sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
    <sonar.clover.version>${clover.version}</sonar.clover.version>

When I look on the jenkins box, I can see that it has generated the clover.xml file (infact in my fiddling I have the clover plugin working on jenkins, so i can see the results there!).

I'm guessing at this stage that there is some issue with jenkins and sonar being on seperate boxes. Any help would be appreciated!

Cheers.


Solution

  • After a lot more fiddling around, it appeared that I needed to change the following:

    <sonar.clover.reportPath>${project.build.directory}/site/clover/clover.xml</sonar.clover.reportPath>
        <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
    

    A good reference was the following: all about pom variables