Change a project name?


(Jonathan Krengel) #1

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?


(G Ann Campbell) #2

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


(Jonathan Krengel) #3

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”.


(G Ann Campbell) #4

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


(Jonathan Krengel) #5

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