- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
Developer Edition SonarQube 9.5.0.56709 Self hosted
GitLab v.15.1
org.sonarsource.scanner.maven 3.9.0.2155 (Java projects)
and
docker image sonarsource/sonar-scanner-cli 4.6 (Python projects)
- what are you trying to achieve
We want SonarQube to automatically set the MAIN_BRANCH
to main
for new projects pushed to sonar via our CI, not master
as we no longer use master
.
SonarQube picks up the correct MAIN_BRANCH
if the project is added to SonarQube FIRST, but this is not possible for us as our projects start with a default CI template that pushes to sonar, so as soon as the project is created in gitlab the bug will occur.
Given it works by manually adding the project, but not when automatically, we’d like to register this as a bug.
It creates risk for us because the subsequent analysis on the the main
branch is not treated as the MAIN_BRANCH
for calculating differences with previous versions, and that we have to delete the analysis history in order to fix the problem. There needs to be a manual process to detect this error has happened and needs time and effort to resolve.
This functionality works elsewhere in sonarqube, so we know it is possible, and it causes us risk of incorrect analysis and manual effort so I think this should be considered a bug.
- what have you tried so far to achieve this
Setting the project id in sonarqube manually after project creation does not correct the problem.
Setting sonar.gitlab.project_id=${CI_PROJECT_ID}
in the CI pipeline does not correct the problem.
Limited options to try as maven plugin and/or gitlab do a lot automatically.