Default branch name doesn't match when scanning GitHub repos


We are using GitHub Enterprise and SonarQube - Enterprise edition - 9.4.
Is there a way to automate the branch names in SQ to match the branching strategy in GitHub ? If I’m working on a main as default branch in GitHub, after the scans in SQ the project still is looking for Master branch to scan and is considering master branch as it’s default branch.

So far we’re doing this manually by deleting the master branch and adding main as default branch, but in future we will be moving all our applications from BitBucket to GitHub which will be a lot to modify manually, I was wondering if there’s is a process or a way to have the projects in Sonarqube match the default branch name as Github.

Thank you in advance !!

Best regards

Hey there.

Two points:

  • If you use the project onboarding wizard, all new projects should mirror the main branch that exists in your DevOps Platform
  • For existing projects – you could use POST api/project_branches/rename to rename branches on many projects at once.