Hi @OlivierK
Is it possible to set the main branch name to the actual default branch name (in azure devops), so that when default branch changes, it is automatically changed in Sonarqube.
Hi @OlivierK
Is it possible to set the main branch name to the actual default branch name (in azure devops), so that when default branch changes, it is automatically changed in Sonarqube.
Experiencing the same issue; am full admin using SonarQube ( SQ ) Enterprise 9.4 - build 54424. We have a repo which was imported into SQ - by default the master branch is empty, the develop branch is being used by the team.
SQ is now whining about ‘misconfiguration issues’ and pointing me to many different screens, global settings, help pages discussing what it was like in 7.4, Python workaround, etc, etc. Blah!
At first glance, this seems an easy problem to resolve - delete the master and rename / set develop as the master, or: ‘Dear SQ, please ignore this one and use that one. Thank you!’
Nope - unable to delete master, can only rename. Unable to rename develop, only delete.
Step-by-step instructions, explaining like I’m a small child or a golden retriever, and actually fixing the problem would be most welcome.
OK - Potential Solution
Note
Steps
Refresh the Projects screen. For the project in question, I now see the analysis stats ( Bugs, Vulnerabilities, Hotspots Reviewed, etc) instead of a ‘blank hole’. Clicking the project name to drill down, I now see this:
Showing the develop branch as the default / main / master.
Is it Possible to change Main branch to Development branch in
Workaround “delete & create” is not allowed by our QA.
We changes flag Detault in AZURE regularly, because we don’t have term “main” or “develop” branche. We have only “release/X.Y” branches and the default is that which have flag “Default” in AZURE.
I’ve changed default flag from release/0.7 to release/0.9 a few hours ago. After rebuild on AZURE I’ve this status in “sonarcloud” :
@OlivierKo - I am in to the same stage, I have scanned my feature branch named ‘test123’ and I could see the right analysis, however it is reflecting in the UI as master, Say for example if I rename the branch name to ‘test123’ in UI by following the instruction which you have provided, tomorrow if I am actually running the scan on master branch, what will happen to my ‘test123’ will I still be able to scan both master and test123 branch?
Thank you!
Having to “rename” the master branch is very unintuitive. The branch is named master why would I rename it? Having to delete my “main” branch and rename the master branch is very confusing. Both branches exist, what I’m trying to do is to pick which one is the default not rename anything or delete anything.
From a UX perspective this situation is very confusing and it would be nice if the UI was updated to reflect a “selection” of which branch is the main branch.
Additionally, github itself stores metadata about which branch is the default branch and thus it would be extra nice if this was simply detected from github and updated automatically. I can’t imagine ever wanting the “main” branch to differ from the “default” branch. Additionally it would be nice to use the same verbage of “default” branch rather than “main” branch, since its also super confusing to have the “master” branch be the main branch but the main branch, which is actually the default branch is not the main branch… You see where this is going.
So to recap, feature requests:
Agree 100% with your comments Justin. It’s April 2023 and we are on 9.9 release this issue just got worse with the defaults changing to “main”. None of our new projects are getting analyzed without hand holding… The “Main Branch” tag switching needs to be much easier.
Hey @justinmchase and @dbrin .
Unfortunately, changing the main branch in SonarQube takes a lot of changes in the underlying database. We didn’t feel comfortable introducing these changes late in the v9.x series as the LTS got closer.
The first sprint to properly prepare for this feature has been completed, so it is definitely coming.
You should be able to change sonar.projectCreation.mainBranchName
under the global Administration > General > Project Creation.
I think you make an interesting point about default vs. main branch, considering this is the verbiage used across all the DevOps Platforms we integrate with (I just checked).
Can I ask that you raise this specific point over at Product Manager for a Day - Sonar Community?
This is also interesting. I’ll make a note to raise the point when we get closer to actually implementing changing the main branch. Synchronization between the DevOps Platform and SonarQube is an important topic for us.
Perhaps we could have just a setting by project, which allow to choose the default branch ?
It will be the branch whose results will be presented by defautl in the UI, whatever its name is.
Hi Colin,
Appreciate the information. Any reason why SonarQube wouldn’t simply display the name of the branch being analyzed? I recognize that it’s rather rare for the default branch for a repo to be anything other than “develop”, “main”, or “master”, but why is SonarQube taking a point-of-view? If a repo calls their default branch “abnormal-and-unintuitive-branch-name”, why doesn’t SonarQube show that?
I’m new here and may not properly understand the feature, but any additional guidance would be appreciated.
Hey there.
I’m not quite sure I understand your point, but let me try:
From a functional point of view: SonarQube doesn’t really care about the name of the branch (although it sets a default if no information is provided during project onboarding). The issue here is really that sometimes the main branch of a project changes, or is misconfigured at first, and to preserve the history of the branch SonarQube doesn’t just “switch” and tack on measures for the new default branch to the old default branch.
From a technical point of view: since it was first implemented, the “main branch” of a project in SonarQube has been synonymous with the project itself. We have to separate those concepts, which takes quite a lot of work in the database. Once that is done, SonarQube will be much more flexible.
Hi all,
So you know, we’re on track to deliver in SonarQube 10.2 the ability to choose a different, existing branch as the main
branch.
Ann
Hello, has this feature been released?
Yes @dbrin – in SonarQube v10.2 finally. The latest active version of v10.x is v10.6.
Thank you!!! Confirmed.
Hello @ganncamp any idea where to find it in sonar Qube?
@shareef_hiasat_saj Searching “change main branch” in the SonarQube docs will take you pretty far.
Thanks @Colin i tried but am talking about sonar qube Cloud paid one, the link is for sonarqub server not cloud
The link is for the SonarQube Server docs because the feature is available on SonarQube Server. But not on Cloud.
Ann
i see thanks
i added vote to have it in future