I know that there is no "new project" button on SonarQube UI. However, I have two branches of the same project that I want to do analysis on. The thing is that since the project names are the same, SonarQube will upload the analysis results of the two branches into the same project on SonarQube Server. How do I configure SonarQube so that one branch will upload analysis results to one project and the other branch will upload results to another project on SonarQube server?

up vote 44 down vote accepted

You might want to look at this part of the Sonar documentation, specifically at the sonar.branch parameter. It seems to be designed for what you want to do, and is working that way for us.

  • 1
    Works for us, too. I tried using sonar.projectKey, but that is not carried to submodules. – ChristophT Feb 6 '17 at 10:18
  • Hi. We use the branch parameter but we do not see any kind of integration. The documentation states: " Two branches of the same project are considered to be different projects [...] issues found in a project A in a branch B1 are not linked to issues found for this project A in a branch B2." So. What kind of branch support is provided by Sonar? Thanks – borjab Jul 12 '17 at 8:53
  • 2
    SonarQube documentation now states that the sonar.branch is deprecated from SQ 6.6 – Jeroen Pot Nov 14 '17 at 16:14
  • Apparently, they have some branch support in the Developer edition. Tough luck... – kap Dec 11 '17 at 15:33
  • Indeed, docs.sonarqube.org/display/PLUG/Branch+Plugin is available only for Developer Edition, which is not free (: – heroin Jan 23 at 13:08

If you use SonarQube Runner, then you have to change the sonar.projectKey property to different values. If you use maven based analyses, then add -Dsonar.projectKey="Something" to your command. Example:

mvn sonar:sonar -Dsonar.projectKey="My project in first branch"
mvn sonar:sonar -Dsonar.projectKey="My project in second branch"

You can change the project name in a similar way with the sonar.projectName property.

  • Tried both sonar.projecKey and sonar.projectName, but couldn't force SonarQube to work on a single project module (the multi-module project has previously been processed by SonarQube as a whole): it always complains that the module is already part of project X... :\ Would have come in handy not to have to wait 10 minutes for each iteration while I tweak maven parameters to get the job to run just right. – Tomislav Nakic-Alfirevic Sep 3 '15 at 11:17
  • 6
    This is not correct. See the answer by Dennis S. below. – Chris Jones Dec 14 '15 at 23:25
  • See answer by Dennis S. and andref above – mjaggard Jan 19 at 11:14

This blog post by the SonarQube team suggests that treatment of branches will be improved in version 6.

Additionally, if you are using pull requests, have a look at its pull request analysis plugins (both GitHub and BitBucket at the moment).

  • Well. We use 6.3.1 and add the sonar.branch parameter but it still seems to create a project by branch. Are we doing something bad or it is just that Sonar didn't implemente a lot of improvements with this parameter. – borjab Jul 12 '17 at 8:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.