Main branch naming strategy

Hello Sonar Community

I’ve been trying to figure out how we best integrate SonarCloud into our work flow on Azure DevOps.
The technical integration between the two platforms works fine. We are able to get PR feedback and Quality gates.

However, my issue is that our flow is that we do all of our work from a branch named: ‘develop’. From there we do feature branches and when we do a release we merge from ‘develop’ → ‘master’.
So my issue here is that when a new project is added from a Pipeline in DevOps (note that a CI pipeline is run on the develop branch, which is our default branch) the project created in SonarCloud will have a [Main Branch] named master. This is quite annoying that the naming of the branches don’t align. It seems like SonarCloud doesn’t use the branch name info when a new project is created.

I’ve tried to force the branch name as a property: sonar.branch.name=$(Build.SourceBranchName)
However that gave me the following issue on our pipeline:

##[error]ERROR: Error during SonarScanner execution
ERROR: Could not find a default branch to fall back on.

Is it possible to have the newly created project in SonarCloud match the name of the branch from which it was published from, so that it matches?

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command: Sonar pipeline plugin

Best Regards,
Steffen