Different Sonarcloud results on local machine and CircleCI server

I’m using Sonarcloud and I get different results when running the same command on local machine and CircleCI service.

I’m using Gradle build system with Sonarqube plugin version 2.7

The command used is identical in both environments
./gradlew sonarqube -Dsonar.projectKey=<project key> -Dsonar.organization=makit -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=<key> -Dsonar.pullrequest.branch=sonar -Dsonar.pullrequest.key=266 -Dsonar.pullrequest.base=development -Dsonar.pullrequest.provider=github -Dsonar.pullrequest.github.repository=<my repo>

The result when run from local machine OS X Mojave (10.14.5):

But when run from CircleCI environment (Debian GNU/Linux 9.6 (stretch)):
https://www.dropbox.com/s/jsgzs48mmqv5gk2/app_-_makit.png?dl=0

What could cause the difference and what is the most obvious thing to check to debug this issue?

Thanks!

1 Like

Found related thread: Code is empty on Pull Request reviews
Which eventually points to a bug in CircleCI: https://discuss.circleci.com/t/git-checkout-of-a-branch-destroys-local-reference-to-master/23781

tl;dr; - Circle destroys local reference to the master and therefore master and feature branches point to the same commit - Sonarqube thinks that there are no code changes.
The solution is to execute git branch -f master origin/master before analysis

2 Likes