Hi, we have the same problem. For some reason, sonarcloud thinks master is the main branch, and ignoes our develop branch and it ignores all our PRs against the develop branch. We dont have admin access to the UI in our org.
I have read all the replies, and it seems we need to do something like this:
sonar.branch.name=develop
every time anyone runs the tool, or it will produce wrong results.
Note that in many CI environments the branch name is auto detected so you should not even have to specify the branch name if the CI integration is done as per Sonar recommendations.
Once you have multiple branches analyzed, in recent enough versions of SonarQube (10.x or the 2025.1 LTA), you may select the one that’s you main branch from the SonarQube UI as per the screenshot below.
Really, all we want to do is get sonar to ignore master, and consider develop as the main branch. It would have been great if there was a way to do this out of the box, but for now we have to find a way to hack it.
A CI wont magically detect or use a branch name, the CI will simply call the command line you indicate in setup page you are given when you first hit “configure analysis”, namely:
Really, this document should include the required params as well, as its impossible to deduce these. As arguably noone will want to analyze PRs against master, the branch should be in the example.
Of course we can make our build tool pass any params we need, but we need to know what should be passed to get up and running.
There are multiple reasons for that. One is that this thread is about SonarQube Server and (as I’m aware from some of your other threads) you’re using SonarQube Cloud. The options vary. This is one feature that hasn’t made the jump from one product to the other.
And since staging was initially created as a short-lived branch, you’ll need to delete it and re-create it after you’ve corrected the pattern. Branch types are immutable.
When you re-create it, make sure to do so without passing a branch name parameter. This means it will be created as main in SonarCloud. You can then rename it to staging.
And BTW, you’ve resurrected a 3-month old thread here. Per the FAQ, please don’t do that.
If there’s more to this that you’d like to pursue, please create a new thread.
Thanks for the reply, but we are still no closer to figuring out how to change the main branch to staging. Even if we create a new long lived branch, I assume this will still not solve our problem that we cant get any PRs into sonarcloud, presumably because it thinks master is the main branch.
I dont think you have covered this in other threads. we havent seen any info on this. If we cant do the steps on the command line, we cant automate it in a build pipline