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
Extracted and started SonarQube server locally
Created a SonarQube project “SQ1” to analyze the first branch “master” of the maven-project
After successful analysis, created another SonarQube project “SQ2” to analyze branch “test” of the same maven-project
Started the analysis on branch “test” using the below cli-command:
mvn sonar:sonar
-Dsonar.projectKey=SQ2
-Dsonar.host.url=http://localhost:9000
-Dsonar.login=215dbbe0ed77a30a37697461815ca91c597d49f9
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:
sonar.branch=“project-name”-private-view
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 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.