We have actually a problem with a Sonar analysis on SonarCloud.io
When (in Gitlab) we try to run a pipeline with a Sonar analysis we get this message:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project fcot-backend: Could not find a default branch to fall back on. -> [Help 1]
It happens on branches analysis but also on master…
It used to work like a charm before, but a few days ago we had to change the nature of the Maven project.
At first it was just a simple Maven project. But now it becomes a multi-module project with the same name…
The problems occurred first on the branch for that new re-factoring. Because of that, we decided to delete the project on SonarCloud.io and launch the analysis again. We hopped that the project will be re-created from scratch and resolve our problem. But it was not the case. Since then we tried to launch some pipeline from master even from a commit before the refactoring, but that doesn’t solve the problem either…
This error case was added recently and it should only appear when there is no branch on SonarCloud that is marked as the main branch, could that be the case in your project? You can check this by going navigating to Your Project > Administration > Branches & Pullrequest.
SonarCloud should automatically mark the default branch on Gitlab as the main branch on SonarCloud when you import a project from Gitlab. Can you check if you have a branch on Gitlab that is marked as default?
Thanks, something else must be going on then!
Could you activate debug mode (you can do this by replacing sonar-scanner with sonar-scanner -X in the .gitlab-ci.yml file).
Do you see a Could not process project branches - continuing without it
message in the log output when running in debug mode?
[DEBUG] 12:45:00.296 GET 404 https://sonarcloud.io/api/project_branches/list?project=groupemutuel.io_fcot-backend | time=16ms
[935](https://gitlab.com/groupemutuel.io/digital-transformation/fcot/fcot-backend/-/jobs/534822227#L935) [DEBUG] 12:45:00.297 Could not process project branches - continuing without it
I’m currently looking into what might be causing the 404 in your case, and I suspect it might have something to do with your project key. Can you share your project key displayed in the right banner when you view your project on SonarCloud.
The project key usually consists of the organization key combined with the project name. In your case that would be groupemutuel.io_fcot-backend, I suspect that is also the value you have configured in your pom.xml under
It seems the key of your project does not follow this convention however, setting the key fcot-backend in your pom.xml or updating the key on SonarCloud to groupemutuel.io_fcot-backend should fix your issue.