Hudson + Maven + Emma / Sonar = Build cycle 2 times

I have a bunch of Maven projects built in Hudson, with Sonar sitting in the sidelines. Sonar gives me Sonar statistics, FindBugs statistics and code coverage.

I noticed that regardless of whether I use Sonar or use EMMA through Maven directly, the entire build cycle runs twice. This includes init (which, in my case, reinitializes the database - is expensive) and unit tests (a few hundred are also expensive).

How can I prevent this? I read a lot, and it seems to be related to the design of the code plugins - to keep uninstrumented classes separate from the instrumental ones.

I tried settings like:

  • Maven Launches: Deployment, EMMA
  • Maven runs: deploy; deployment in sonar upon completion
+3
source share
2 answers

Sonar documentation recommends starting the sonar plugin in 2 steps: -

mvn clean install -Dtest = false -DfailIfNoTests = false

mvn sonar: sonar

Tests bypass in the first phase and are performed implicitly in the second stage.

One alternative is to run the following command: -

mvn clean install sonar:sonar -Dmaven.test.failure.ignore=true

but it will run the tests twice - as you already found.

+1
source

To add @Strawberry to the answer, you can reuse unit test reports instead of running them again. See Reuse existing unit test reports in sonar documentation.

Once this is done, you can configure the following in Hudson

clean deploy sonar:sonar
+1
source

All Articles