0

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?

MisterStrickland
  • 858
  • 13
  • 30

1 Answers1

2

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.

G. Ann - SonarSource Team
  • 20,814
  • 3
  • 32
  • 60
  • Thanks for the answer G. Ann. It makes sense that it is like that by default :-) – MisterStrickland May 06 '16 at 20:36
  • Hi G. Ann. I have another question: JaCoCo takes approximately 1 minute to run. `sonnar-runner` also takes around a minute. The "full" execution of sonar in Ant is taking around 10 minutes for a small project. Any idea why that is happening? – MisterStrickland May 06 '16 at 20:50
  • 1
    No @Phil, I don't. You might want to start a thread on the Google Group (https://groups.google.com/forum/?pli=1#!forum/sonarqube) – G. Ann - SonarSource Team May 16 '16 at 11:55