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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the answer G. Ann. It makes sense that it is like that by default :-)
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?
No @Phil, I don't. You might want to start a thread on the Google Group (groups.google.com/forum/?pli=1#!forum/sonarqube)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.