Two branches are being treated as one

I’m using Azure Devops and have been able to get the CI/CD working well for PR quality gates, etc. However, the issue is that when I run the analysis on two branches (dev and master), they’re both sending the results to the same branch in sonar (main/master). The branches are not similarly named (dev vs master) at all or anything so I don’t understand why it’s consolidating them.

In the pipeline logs for sonar analysis, I notice that running it on “dev” produces a link which takes me to the overview for the project since that defaults to the main branch. The same log for “master” produces a link that ends in ?branch=master, however it’s clearly highlighted as the “main branch” and shows history for the other one (dev).

I have another branch and feature branches which show up just fine as independent branches, but I have no clue what to even begin looking for to make my dev branch show up as separate from “master” in sonarcloud.

I found the issue, and it’s really odd… but I guess sonarcloud defaults the “main” branch to whichever is the first one you push, and it names it master even if it’s not master. So if that branch was really dev, it is now your main branch; every time you use the sonar analysis step, it is going to say it’s updating the main branch which is already named (in sonar) “master”. When you do the analysis on the actual “master” branch, it’ll say it’s going to ?branch=master which is effectively the same in this case since Sonar thinks that master is the main branch.

To fix this, I simply renamed the main branch to “dev”. Then, once I pushed both dev and master, they started appearing in two different branches in Sonar.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.