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
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.
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.
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.