I had the following configuration for my Jenkins job:
First clean and build the maven project, then run the unit tests and static analysis: clean install sonar:sonar
The problem was that install
and sonar:sonar
each ran the unit tests which effectively doubled the build time.
I fixed this by changing clean install sonar:sonar
to clean install -DskipTests
and running Sonar using the Jenkins sonar plugin. Now the unit tests ran only once and sonar showed the results, but Jenkins didn't know about the tests anymore.
My guess is that Jenkins is only looking at the surefire-reports folder after building, not after Sonar (which is a post-build action).