Scanning project for Github PR using the Jenkins Github Branch Source Plugin is not reporting new code

SonarQube: Enterprise Edition Version 7.8 (build 26217)
SonarScanner: 3.3.0 and 4.4.0

I am trying to get coverage percent on new code for Github PR builds and have tried several combinations of settings to the java sonar scanner tool via the jenkins plugin.

Here’s the command:

/Users/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_4.4.0/bin/sonar-scanner -Dsonar.projectVersion=88.0.0**** -Dsonar.login=**** -Dsonar.cfamily.threads=6 -Dsonar.pullrequest.github.repository=org/repo -Dsonar.pullrequest.key=3249 -Dsonar.github.pullRequest=3249 -Dsonar.pullrequest.branch=branch_to_merge_to_master -Dsonar.pullrequest.base=master -Dsonar.scm.revision=e5954ebe07b031b9dcb55477a6c25f1174597a8c

I see this in the log:

INFO: SCM provider for this project is: git
INFO: 9 files to be analyzed
INFO: 9/9 files analyzed

And those are the nine non ignored files modified in the PR, two of which are completely new swift file, which is correct.

Looking at the PR, I see those nine files listed in the code header with what seems like accurate coverage information. The two new files are 100% covered based on the green bars on the left side when I open up the code viewer.

But when I look at the summary page its showing ‘—Coverage on 0 New Lines to cover’ and the code file browser shows no coverage data on it. Attached two screenshots with sensitive info cropped


Welcome to the community!

In fact, in your screenshot, it appears that the coverage column is empty for both files. You’ve provided your analysis command, but I don’t see you passing any coverage reports in it. Are they specified in a separate file? Because every indication is that analysis simply isn’t finding any coverage reports.


Yes I am using a****
sonar.sources=./FinderUI, ./FacilityUI
sonar.exclusions=build/**.*, Carthage/**.*

And here’s a cropped screenshot of one of the new files added in the PR saying it is covered by tests:

Also here is censored output from the sonar scanner command:
sonar-log.txt (4.6 KB)


I’m a little confused here. You say

And you provide a screenshot showing a coverage marker. But those lines don’t have the “new code” yellow highlight. At the same time, your homepage screenshot shows “-” for coverage and duplications as well. Coverage aside, “-” for duplications is generally an indication that there’s no code in the PR.

You say you’ve added two new Swift files. This may sound like a dumb question, but do they contain lines of code or just comments and whitespace?

As a side note, I just picked up on the fact that you’re running SonarQube 7.7, which is past EOL. The current LTS is 7.9.4 and the current version is 8.4.2. You should upgrade at your earliest convenience. It’s possible that some off this has been worked out in the meantime, although since I’m not clear on what’s going on, I can’t promise that.


The screenshot of the coverage marker is from one of the two swift files that didn’t exist before this PR so it should be marked as new code. And I think that is the main issue here, nothing is actually being marked as new code in this PR and I am trying to understand why. My first guess was for sure the old version of the sonarqube server but I am just an end user and can’t upgrade the server. So I cam here hoping to find a solution hoping I was just missing something.