Branch analysis of default branch 'develop' is placed on master in SQ

Versions:
SonarQube: 7.4 (Developer edition)
DevOps extension: 4.7.2

In DevOps I have the following branch structure:

  • master
  • develop (default & compare)
  • [short live branches]

When I create an analysis of the master branch on DevOps, the result is visible in the master branch on SonarQube. Which works as expected.
When I create an analysis of a short live branch on DevOps, the result is visible in the short live branch on SonarQube. Which works as expected.
When I create an analysis of the develop branch on DevOps, the result is visible in the master branch on SonarQube. Which doesn’t works as expected.

As a workaround I set: ‘sonar.branch.name=$(build.sourcebranch)’ which results in a ‘refs/heads/develop’ branch on SonarQube. Which is fine by me.

BUT!
When I want to include the PR build analysis, the following error occurs on a PR scan to the develop branch: “ERROR: Pull request with branch does not exist on server: develop”.
I can create a workaround for this by setting the sonar.pullrequest properties.
But this results in the following error on a PR scan to the master branch: “ERROR: Pull request with branch does not exist on server: refs/heads/master”

I’ve checked the source code on github and according to this function (sonar-scanner-vsts/prepare-task.ts at master · SonarSource/sonar-scanner-vsts · GitHub) the sonar.branch.name should be filled with “develop” when I run an analysis on the develop branch.

Please help, because now I really don’t know how to fix this.

Hi,

Have you set the default branch as “develop” on SonarQube as well ?

Mickaël

To make the ‘develop’ branch the main branch, I need to rename the main branch from ‘master’ to ‘develop’, right?

Yep !

Apologies for the late reaction, but thanks for the tip!