Change a project name?

I pre-provisioned a project before analysis, but the analysis changed the Display Name. Can I change it back without deleting the project and recreating it?

Hi,

You can easily change a project’s name at its next analysis using the sonar.projectName parameter. In fact, that’s very likely how it got changed the first time. Depending on your build/analysis technology, you may need to override the value picked up automatically from the project itself by passing -Dsonar.projectName=[new name] on the analysis command line.

 
Ann

2 Likes

Hmm, that doesn’t match with documentation. The page located here: https://sonarcloud.io/documentation/analysis/analysis-parameters/
states “If there is already a name in the DB, it won’t be overwritten”.

Hi,

I was writing from memory. Your challenge pushed me to actually test, and the test showed that I’m right.

After squinting at the documentation for a few minutes, I sorted out my confusion. Here’s the passage you’re referring to:

<name> for Maven projects, otherwise project key. If there is already a name in the DB, it won’t be overwritten

The key point is that that’s in the “Default” column. In other words, the default value is the project key, but if you don’t provide a project name and a project name was previously set (by whatever method) then your existing project name won’t be overwritten with the project key.

 
HTH,
Ann

That makes sense and matches with what I’m seeing. Thanks

Hi,

given the answers it is not clear to me if there is any way to rename a project after that it’s been created.

@jkrengel_foodsby, did you find a way to rename your projects?

Thanks,

Hi @mbaumeler,

Welcome to the community. Here’s your answer:

 
Ann

Hi @ganncamp ,

some of my initial tests didn’t work like that but now I can apply this approach every time.

Thanks

Hi,

I have a similar question. I am using bamboo to build an app and when I run the task it adds a name “develop” next to my project name in SQ. How can I remove that branch name, please? see attached screenshot.

@ganncamp any comments on my question above please?

Are you using a sonar-project.properties file? If so, there should be a parameter called sonar.projectName you can modify.

If you’re using something like MSBuild you can also define that parameter in the call.

Cheers,
Robin

1 Like

Hi @RobCo

We are using Bamboo for this project’s build

I’m not talking about your build server (Bamboo), I’m talking about how you integrate SonarQube into your build (SonarScanner for MSBuild, SonarScanner for Maven, etc).

Cheers,
Robin

Hi, I’m facing similar issue when trying to change project name via sonar.projectName property. In my case, I’m using a custom sonarqube.properties file with sonar.projectName setting and I’m passing in this sonarqube.properties file path via “sonar-scanner -Dproject.settings”. However, I’m not able to change the project name this way, it looks like the .projectName setting is been ignored, all other settings present in the .properties file are working fine. Thoughts?

Hi @Joao_Melo,

Welcome to the community!

Try adding the sonar.scanner.dumpToFile=[path to file] parameter to your analysis. There’s a hierarchy to how analysis parameters are set and overridden so a good first step is verifying the value analysis actually gets for that parameter. Then we can go from there.

 
Ann