0
votes

I created a job in Jenkins that executes sonnar-runner against all the projects in my repository. This job is independent from code coverage and runs a few times a day.

On the other hand, I want code coverage to happen upon a build (using JaCoCo) and import the reports into Sonar using Ant.

I set up my environment and added the JaCoCo and Sonar plug-ins to the Ant lib directory. When I run the Ant target I can see the results of JaCoCo locally in XML and HTML.

All I want is to upload these results to a remote SonarQube instance. However, after setting up the Sonar properties and adding <sonar:sonar> to my build.xml I realized that Sonar seems to be running static analysis against my project.

How do I set up Ant to only run code coverage for a project?

1

1 Answers

2
votes

You can't run only a small portion of the full analysis.

Imagine for a moment that this were possible: Let's say that once an hour a "coverage only" job runs that updates the coverage on my project.

  • At 8 a.m. I start with a project with 6 LoC and 50% coverage.
  • At 9 a.m. my project has "6 LoC" and 20% coverage
  • 10a.m.: "6 Loc" and 10% coverage.

Has someone been removing tests? Or adding new, uncovered LoC?

I have no way of knowing because my partial analysis has put the SonarQube project in a bad state.

And this is why there's no way to run only part of the analysis.