SonarCloud thinks feature branch was created from a different branch than it actually was

Our branch structure is as follows:

A main branch that we create releases from - “integration”
A set of team branches that we merge into integration - “team1”, “team2”, etc
Feature branches that we create per-ticket and merge into our respective team branch.

I’m currently trialling a migration to SonarCloud, and have created examples of these - integration and team branches as long-lived branches, feature branches as short-lived.

My feature branch is showing in the SonarCloud UI as having been created from integration, when actually it was created from a team branch.

How does SonarCloud detect source branches, and how can I resolve this issue with my setup? The true state of things is that team branches were created from integration, and feature branches were/are/will be created from team branches, and we’d need SonarCloud to reflect that.

Hey there.

Using short-lived branch analysis… it doesn’t even guess, it just defaults to your main branch. You might be able to put some logic in your build to set a different sonar.branch.target analysis parameter… but it gets tricky fast.

When using Pull Request Analysis, however, this information should all be available in the build and configured automatically.

With a more complicated branching structure, it’s probably best to stick to pull request analysis.