SonarQube main branch switch

Hi all!

Here my configuration

  • SonarQube Developer Edition v2025.6.1 (117629)
  • Deployed from zip as Window Service

I’m trying to switch the main branch reference from the current develop to the new master.

Our Housekeeping Global Configuration cointains the branches both. (develop for backward compatibility)

I switched the main branch on our onpremise Azure DevOps and runned multiple times the nightly build using master as reference branch but in SonarQube the main branch is still develop

master branch doen’t appear in Project’s Settings => Branches & Pull Rrequests.

So in Project’s Settings => New Code I can’t choose master as Reference branch

Can anyone help me to figure out the this problem?

Thank you!

Hi,

This doesn’t mean that both branches are under analysis. Only that when/if they show up, they shouldn’t be deleted.

Yes, because you have to do the switch in SonarQube as well.

Have you analyzed the main branch yet? Once it’s under analysis, you’ll be able to make it the main branch in SonarQube.

 
Ann

Hi Ann!

Yes, we’ve already analize master but it doesn’t appear in branches list

Our DevOps build pipeline, SonarQubePrepare@8 task

In SonarQube Server, Project Settings => Branches & Pull Requests

Hi,

I’m going to assume that master analysis succeeded on the CI side. Can you check Administration → Background tasks for any errored jobs? If you analyzed it but it’s not showing up, it sounds like it might have errored-out on the server side.

 
Thx,
Ann

Hi Ann,

no tasks failed

Can I check something else?

Thank you!

Hi,

Okay, can you share the analysis log of your master branch?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

Hi Ann,

here the analysis log of master branch with verbose enabled

StaticAnalysis.zip (1.0 MB)

Thank you

Hi,

Thanks for the log. It leads me to think this may be a chicken/egg problem:

The part of real interest here is this:

&branch=develop

You’re analyzing master; why is it requesting develop?

I think what’s happening is this:

  • SonarQube thinks your main branch is develop
  • ADO knows your main branch is master
  • When you analyze your main branch, there’s no need to send the branch name because it’s the default, so sonar.branch.name isn’t specified on the ADO side in the analysis
  • When the unparameterized request reaches SonarQube, it responds with default branch information: develop

Thus, you analyze master and end up updating develop.

To get out of this, I think what you need to do is run an analysis with the manual specification of sonar.branch.name=master. That will create the master branch in SonarQube. You can then make it the main branch, and from there you should be able to remove your manual sonar.branch.name=master configuration.

Does this make sense?

 
Ann

Hi Ann,

it works!!!

Thank you!!!:heart:

1 Like