I’m using the gradle sonarqube plugin (2.6.2) to analyse a Java project, using CircleCI.
It’s analysing the master branch fine, but when I use ‘-Dsonar.branch.name’ to analyse a feature branch the analysis runs through and the branch is created within sonarcloud, but the code is empty and there are no issues listed.
Note that the other sonar properties (organisation, project, etc) are set from within the gradle build, and it’s creating the branch in sonar in the correct project so the connection to sonar seems to be working.
I’m running gradle in debug mode and it looks like it’s successfully creating a report (size = ~1MB) and uploading it with a 200. It’s just not showing anything in the UI.
18:40:36.174 [INFO] [org.sonarqube.gradle.SonarQubeTask] Analysis report generated in 392ms, dir size=1 MB
18:40:36.782 [INFO] [org.sonarqube.gradle.SonarQubeTask] Analysis reports compressed in 607ms, zip size=947 KB
18:40:36.782 [INFO] [org.sonarqube.gradle.SonarQubeTask] Analysis report generated in /home/circleci/app/build/sonar/scanner-report
18:40:36.782 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Upload report
18:40:38.211 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] POST 200 https://sonarcloud.io/api/ce/submit?organization=xxxxxxxxxxx&projectKey=xxxxxxxxxxx&projectName=xxxxxxxxxxx&characteristic=branch%3Dsonar&characteristic=branchType%3DSHORT | time=1428ms
18:40:38.213 [INFO] [org.sonarqube.gradle.SonarQubeTask] Analysis report uploaded in 1430ms
18:40:38.215 [INFO] [org.sonarqube.gradle.SonarQubeTask] ANALYSIS SUCCESSFUL, you can browse https://sonarcloud.io/dashboard?id=xxxxxxxxxxx&branch=sonar&resolved=false
I’ve set up a new project and it’s doing the same thing - the master is analysed fine, but the SLBs are all empty. Interestingly I noticed that the coverage estimation is different on each of the SLBs, so there is something happening somewhere!
This is the expected behaviour if your branch is considered as “short-lived”. Only the new and modified files, compared to the “target branch”, are displayed and can contain issues.
By default branches are short-lived if their name does not start with “branch” nor “release”.
Is it your case?
See https://sonarcloud.io/documentation/branches/overview/ for more details.
build and scan merged code with “sonar-scanner -Dsonar.branch.name=$BITBUCKET_BRANCH” where $BITBUCKET_BRANCH is the name of the short lives feature branch.
Could the issue be that we are analysis the post merged code?
I’m having the same issue. Initiaaly master has 400k lines of code now with short lioved branch has 390k Lines of code. When I do sonar.branch.name=shortlivedbranch. but it is empty. Please help me asap
I’m having the same issue.
run:
gradle sonarqube
-Dsonar.branch.name=shortlived.
Could you tell me any tip used. When I did with out branch name it is default doing on master but when we analyse with branch name then the analysis is empty.
The biggest Issue I have with this implementation is that finding newly introduced bugs on a short-lived branch is great; however, our dev teams want to know, on their short lived topic branches, that they are actually fixing issues that SonarQube is detecting, which are assigned to them, post triage. This is not happening. When an issue is assigned on the long lived branch, a dev will then take out a bugfix branch to fix the issue, build and analyze, then go to the web interface to find out if their changes have actually fixed the issue present on the long lived branch. Unfortunately, it only shows the generic “No Issues. Hooray!” message. Obviously, this is a major short-coming of SonarQube. What dev team wants to go through branch iteration, after branch iteration, which is a huge process even in an agile environment, to make sure that their bug fixes that sonar is detecting, are actually being fixed, only after their bug-fix branch is integrated into the long-lived integration, or release-candidate branch, which will then allow them to see the issue “disappear”. SonarQube, please fix this. It’s frustrating and causes a major strain on organizations who are migrating to SonarQube.