Fork-based Git workflows
When your team works with a fork-based development model instead of using a centralized Git workflow, analyzing your branches with SonarQubeâ„¢ results in the same Sonarâ„¢ projects for your fork and your origin repository, because by default, the project key is the same in both repositories.
To differentiate the origin and its forks, we recommend that you only analyze pull request branches.Â
Bitbucket creates these branches for every pull request, e.g. refs/pull-requests/1/from
for the pull request with ID 1.
These branches can be used to analyze your pull requests from forks to upstream only by passing the pull request branch name to
-Dsonar.branch=pull-requests/1
or
-Dsonar.branch.name=pull-requests/1
Include Code Quality for Bamboo can do this automatically. For other CI systems, the pull request branch name has to be passed manually.
Include Code Quality for Bitbucket supports pull request branches by enabling the option "Forking workflow: Use special pull request branches" in the "Advanced" tab of the app's repository settings:
SONARâ„¢, SONARQUBEâ„¢ and SONARCLOUDâ„¢ are independent and trademarked products and services of SonarSource SA: see sonarsource.com, sonarqube.org, sonarcloud.io.