Jacoco Code Coverage is shown as 0% after SonarQube server update

Sonarqube Server: 6.7.7 LTS (Upgraded from 6.7 LTS)
DB: MySQL
Env: EC2, t2.large | Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-1088-aws x86_64)
Projects Run for Analysis: Java | Spring boot
SonarJava: 5.13.1 (build 18282)

I updated the Sonarqube server from 6.7 LTS to 6.7.7 LTS a few days ago. Everything went well and the update was successful.

Actual way of updating:

  1. Upgraded the server in the traditional way. Download the sonarqube set-up, paste it in a folder.
  2. Stop the old version, copy the configs. Start the server from the new folder
  3. Once started, the sonarqube will ask for DB migration tapping on OK, the DB migration completes and sonarqube will become live.

Problem:

  • After the update, I’m not able to see the code coverage for the projects that are run newly.
  • This means I was able to see the code coverage for a project and I ran the Jenkins job to update the code coverage. Now, the code coverage is showing 0%.
  • I can see locally on my machine that the code coverage is more than 50%. But not on the SonarQube server.

Solutions tried so far:

  • I thought the sonar properties are not set correctly and did some tweaks. - NO HELP
  • I thought changing the project key will resolve the problem - NO HELP
  • I thought of setting up SonarQube on my local machine and run the analysis - VOILA, CODE COVERAGE WAS SHOWN.
  • Just to make sure again, I ran a project which had a Code coverage of about 30% on the EC2 instance (where I’m having the problem) - Code coverage turned to 0%. Ran the same job on my local machine, code coverage showed as 30%

I’m unable to find the root cause for this since if it was a DB migration problem, all the projects should have been 0% regardless of the analysis was done prior to server update or later.

Please enlighten me to resolve this problem.

hello,

do you create XML coverage report during your build? If so, you will need sonar-jacoco plugin to process XML report. This plugin is included by default in newer versions of SonarQube, but you will miss it in 6.7.x version.

If this doesn’t fix your issue, try to run your analysis with debug logs enabled, and post them here.

You are a lifesaver!! The issue got resolved after I installed the plugin

@saberduck I’m relieved that the issue is resolved. But I’ve one doubt. I ran the same code in my local without having to install the sonar-jacoco plugin and it still showed the code coverage. Any idea how did it work? I’m double checked just now that it’s not installed on my local machine.

It depends whether you create XML report or not. There is still deprecated functionality available in SonarJava to read binary exec report for coverage. However, when it detects that there is also XML report created, it will not read the binary report, but delegate to the jacoco plugin to read the XML report.
If there is no XML report, it will read the binary report to provide coverage.

This is a temporary mechanism while both binary and XML reports are supported to avoid the coverage report to be submitted two times. While it sounded like good idea when we developed it, in retrospect I think it was a mistake, because it causes too much confusion. Hopefully we will be able to drop support for reading binary reports soon.

Thanks a lot for the explanation.