Is it possible to analyze different branches of a project in different SonarQube projects?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube version used: Community Edition Version 9.2.4 (build 50792)

  • what are you trying to achieve
    I am trying to analyze different branches of a maven-based Java project in different SonarQube projects.

  • what have you tried so far to achieve this

    1. Extracted and started SonarQube server locally
    2. Created a SonarQube project “SQ1” to analyze the first branch “master” of the maven-project
    3. After successful analysis, created another SonarQube project “SQ2” to analyze branch “test” of the same maven-project
    4. Started the analysis on branch “test” using the below cli-command:
      mvn sonar:sonar

Step 4 results in the below error:
“The ‘sonar.branch’ parameter is no longer supported. You should stop using it. Branch analysis is available in Developer Edition and above. See Automatic Branch Analysis & Pull Request Decoration Tools | SonarQube for more information.”

  • My question/query:
    1. Is it possible to analyze different branches of a maven project by creating different SonarQube projects?
    2. if yes, what could be going wrong as the cli-command does not include “sonar.branch”?



Welcome to the community!

At a guess, the value that feeds this parameter is being “helpfully” inserted by your environment. The scanner is then picking up those variables to “helpfully” auto-gen the parameter key/value pairs.

You can add -Dsonar.scanner.dumpToFile=[file path] to your command line to see all the parameter values analysis is getting. You may need to unset some envvars before analysis runs.



I generated a configuration dump using the -Dsonar.scanner.dumpToFile=[file path] property.
I observed that the “sonar.branch” parameter is indeed passed to the analysis as below:
But the “sonar.branch” or any other SonarQube parameter is not present in my environment variable list.

Should I consider “sonar.branch” property is auto-generated by the scanner as it is not inserted by the environment or Is there any specific environment variable that I need to unset?



The scanner looks for some envvars & automatically populates analysis parameters from them. You’ll want to unset




The above environment variables are not seen in my environment. But while trying to trace these variables to the scanner I came across a section of code in one of the pom.xml files where “sonar.branch” parameter was being set. Removing this line helped resolve the issue.

Thanks for guiding me through,

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.