Changing Master branch for sonarqube

Hi @OlivierK /Team,

Actually we have a requirement here basically the similar one , so As of now we will be using Sonarqube enterprise version soon and will be analyzing lot of repos including different branches and pull requests which we have already done POC and working as expected.

In the same way we have monitoring tool that we will be using as Datadaog where we have integrated Sonarqube with datadog to get metrics of sonarqube dashboard into Datadog which is also working as expected during our POC, But one limitation with getting metrics from sonarqube into datadog is that We can only get metrics related to master(main Branch) and we cant get metrics related to any other branches .

So One work around we are looking here is we wanted to change the current release branch to master (main Branch) in Sonarqube so that every release we will be updating that and we will be getting the metrics subsequently to Datadaog.

Hope you understood my requirement? Can you please let me whether do i need to flow the above process so that our release branch will be a default branch in Sonarqube so that I can metrics into Datadaog ?

is there any other alternative approach regarding this to implement??

Hi @OlivierK ,

As you said you don’t need to do any workaround for the above thing , But Datadog clearly mentions below in their docs

" Projects in SonarQube often contain multiple source control branches. This integration can only collect metrics from the default branch in SonarQube (typically main )"

So I have even closely worked with datadog Tec guy and even he said that we can only get metrics from default branch (which is master as of now) , But we dont want these to be master always as we want the default branch to be varied based on our release ?

For E.g., for april release I want release/april as default branch
for May release I want release/May as default branch

So that data dog can get metrics for that particular release ? So can you please let me know Is there any such way we can change the default branch as per my release?

@vinodkumar4b9 (sorry for the unexpected close, I was confused by the title that does not describe the problem well)

I think there are 2 different aspects to your problem:

  • The way you manage release branches in SonarQube (which may not be as best practices)
  • The Datadog limitations

Branch management in SonarQube
You’re stating that you have one branch per monthly release. I am not sure this is what you should do.
Question: Is the April release, May release, stop points of a Main release branch that is released monthly ? If so, they should not be different branch, simply a single branch with successive “points of analysis” (versions) in time, and Datadog should simply collect the metrics for that branch over time.
It would only make sense to have one branch per month release if you need to fork the code for each month (eg if you have to issue patches on each month release).

Well you’re trying to fix a limitation of Datadog with a workaround on the SonarQube side… I don’t think this is a good idea. You should not modify data on the SonarQube side to solve a datadog problem. You should rather push datadog to provide a solution.

Datadog limitations
I don’t know datadog that much, just discovering from what you explained. I hear 2 different limitations:

  • Datadog can only store metrics for a single branch of each project
  • This branch is hardcoded to be the main branch

I also understand between the lines that you don’t have control on the API calls that are done, it’s built in in datadog (ie you did not develop the integration yourself). If I am wrong on this let me know.

I would push Datadog to improve in 2 steps:

  • In a first step ask them to allow to specify the branch to collect metric from. With this:
    – If you change to a linear release branch as explained above, then selecting that release branch would solve the problem
    – If you don’t want to or can’t change to a single release branch, you could change the branch name you want to collect every month so that datadog picks up the new branch each month (honestly this solution is probably less elegant and less within best practices than the first one)
  • In a second step, ask them to allow collection of metrics for several branches of a projects. modern project development practices ALWAYS imply to manage several branches and I see it as a major (unacceptable ?) limitation that datadog cannot cope with this…


Hi ,

I have opened a new thread here , It seems you have closed this and reopened again , Any way Can you please give us the required details here regarding the above question ?

Please let me know if you need any additional details

Hi @OlivierK Thanks for your detailed explanation on this as you said regarding this Data dog needs to fix this from their side and they said they will raise a feature request to do that which is out of our control and not sure when they will come up with that feature.

On the other hand , what I am trying here is Can we make release branch code as default branch in Sonarqube so that whenever release branch is scanned , all metrics should go to master (Main Branch) by changing the naming convention so that everytime datadog can pick up those metrics which we might use them for thae duration of that release , After that again lets say our april release is done and we will create may release branch now I want this may release barnch metrics to push as main branch in sonarqube dashboard so that datadog can pick this ?

In that way for every release we will be able to get metrics from datadog than getting it only from master which might not have recent code changes to scan .

Hope you are clear with my question ? In a Nut shell is there any option where I can send my release branch metrics to sonarqube main branch so that from there Datadaog can pick that up ?? Awaiting your response on this ??

Thank you so much for your time for the above things too