- ALM used: GitLab
- CI system used: GitLab CI
- Scanner command used: SonarScanner CLI 6.1.0.4477
- Languages of the repository: C++
- Project: Private SonarCloud project
- Error observed: “main” branch has not been analyzed yet. on the Main Branch thumb
- Steps to reproduce:
- Potential workaround: unknown
Hello Sonar Team,
I’ve been trying to solve this problem for several days. I have read and reread all the forums that had the same symptoms as mine. But no solution has solved it.
I’m new to Sonar and I followed all the steps to create a project on SonarCloud. This morning, I decided to delete the project and recreate it from scratch, but I still have this problem of the “main” branch not being analyzed.
Everything works fine with the scanner. The Quality Gate Status is PASSED for the first Merge Request that activates the Sonar analysis on our GitLab project.
FYI, the first MR is not yet merged and still under review.
Hi,
You will have the message “main” branch has not been analyzed yet" until you analyse a branch which name is “master” or rename sonar project main branch.
You can rename the “main” branch of youre sonar project in branches settings
.
Some information about branhces settings could be found in this documentation Branch analysis - SonarCloud
@Bachri_Abdel I renamed the “main” branch with “master” as suggested. But it doesn’t work. I still have the message “master” branch has not been analyzed yet. with the new name.
Hi @Emmanuel_Delalande,
Do you have a master or main branch in Gitlab ?
You should analysis the branch you renamed as main.
Yes I have a “main” branch.
I only analyzed my first MR after recreated the Sonar project.
Not yet merged.
Hi @Emmanuel_Delalande,
To clarify, the name of the main branch should be set to “main” in SonarQube. Once you perform an analysis of the main branch, the message stating branch has not been analyzed yet will no longer appear.
If you have any further questions or need assistance with the analysis, feel free to reach out.
Hi Bachri,
My problem is solved.
Just add -Dsonar.branch.name=main to the scanner CLI.
1 Like