We have used the sonarcloud API SonarQube Cloud to create projects programatically. We used the name key to set the project name and while the sonar analysis was running on a branch, it was all fine. However, after merging the sonar analysis PR (i.e. using https://www.npmjs.com/package/sonarqube-scanner to run the analysis on multiple projects in a monorepo) to main, all projects got renamed to the repo name.
Is there a requirement for every analysis to run with the project name set otherwise it gets overwritten? This is the documentation I used for building the scanner options, and I can’t see this behaviour mentioned in here -Parameters not settable in the UI | SonarQube Cloud | Sonar Documentation.
Was this via the API when you were creating the project?
Projects can’t be renamed from a non-main branch
Take a look at what parameters you’re passing in analysis. sonar.projectName is actually optional, but when you pass it on a main-branch analysis, that’s the project’s (new?) name.
So run analysis one more time with the sonar.projectName value you want and then either delete the parameter from your configuration or leave it set to the correct name.
Nice find! Since a default value is being picked up automatically, you’ll need to override it. It’s probably easiest to add it to your analysis command line: -Dsonar.projectName=[the right one].