Showing default branch in UI

  • Which versions are you using (SonarQube: 8.5 Community Edition, Scanner: msbuild-4.10.0.19059-netcoreapp2.0)
  • What are you trying to achieve (Show my default/main branch in UI instead of master)
  • We are using Jenkins for CI with GitHub.

master branch is typically corresponds to what’s being developed for your next release. However our default branch’s name is dev. So our workflow is dev -> qa -> staging ->master
So by default new code check-in to dev branch.

  • The build process checkout dev branch, and pull down latest code.
  • Then executes Msbuild scanner. I have noticed msbuild scans currently checked-out branch, which is dev in my case. (This is expected behavior)
  • In SonarQube I noticed the updated scanning report from dev branch.
  • At this point code not merged from dev to master branch yet.
  • ISSUE The UI still shows master instead of my default branch dev

Is there anyway in UI to change the default branch to dev? Is this possible in community edition

(I understand that branch analysis is supported in developer edition but I do not want to scan other branches. I am only interested in showing my default branch in UI)

Hi,

You can use the api/project_branches/rename web service. It’s not exposed in the UI in CE (because we didn’t think it would be needed) but it’s available. You’ll find the on-board Web API docs linked from the page footer.

 
HTH,
Ann

Thanks this worked

curl -u ADMIN_TOKEN: -X POST “http://localhost:9000/api/project_branches/rename?name=dev&project=prokectkey