# Unable to update project name via sonar.projectName property

**URL:** <https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842>\
**Category:** SonarQube Server / Community Build\
**Tags:** scanner\
**Created:** [March 23, 2023, 1:00am UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842 "2023-03-23T01:00:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maruTA-bis5](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/maruta-bis5/32/7562_2.png) [@maruTA-bis5](https://community.sonarsource.com/u/maruTA-bis5)\
**Post date:** [March 23, 2023, 1:00am UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842/1 "2023-03-23T01:00:11Z")

</div>

I have a project in our SonarQube instance. For some reason, I want to rename the project via `sonar.projectName` parameter.

In the document, `sonar.projectName` is describes that:

> If not provided and there is already a name in the DB, it won’t be overwritten.  
> [Analysis parameters](https://docs.sonarqube.org/latest/analyzing-source-code/analysis-parameters/#optional-parameters)

But I couldn’t rename the project via `mvn sonar:sonar -Dsonar.projectName=newName`.

In the source code, the `sonar.projectName` parameter is described that:

> Optional name of the project, used only if the project does not exist yet.  
> [https://github.com/SonarSource/sonarqube/blob/bcd75f36ce26a17eeea53b392215414b2ba9c000/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/SubmitAction.java#L73-L78](https://github.com/SonarSource/sonarqube/blob/bcd75f36ce26a17eeea53b392215414b2ba9c000/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/SubmitAction.java#L73-L78)

Which is correct? Is it not possible to change the project name without recreating the project?

Our environment:

- SonarQube Community 9.9.0 deployed from zip
- SonarScanner for Maven (sonar-maven-plugin): 3.9.1.2184

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [March 24, 2023, 5:36pm UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842/2 "2023-03-24T17:36:48Z")

</div>

Hi,

Those docs also say:

> `<name>` for Maven projects

Is it possible that you provided `-Dsonar.projectName` once on the command line, and it was renamed until your next analysis? Because with a Maven analysis, your pom `<name>` value will be automatically passed at each analysis.

Maybe just update the `<name>` element in your POM?

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![Erik\_Vickroy](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/erik_vickroy/32/53943_2.png) [@Erik\_Vickroy](https://community.sonarsource.com/u/Erik_Vickroy)\
**Post date:** [February 6, 2024, 5:48pm UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842/3 "2024-02-06T17:48:27Z")

</div>

Just to confirm, it sounds like when using the Sonar Scanner for Maven, there is no way to prevent it from ALWAYS updating the Project Name from the pom file’s “name” element? That is consistent with the behavior we are seeing. This is causing us a lot of grief. We use the Sonarqube API to pre-configure all of our Sonarqube projects so the project names match the project names in our SCM. Java Maven projects appear to be the only projects that keeps flipping the sonar project name after every run. It seems the only way we can stop this issue is to add custom logic in the build pipeline to always overwrite the pom file’s “name” element with the user friendly project name before every sonar scan. This behavior makes sense as a default value if the project doesn’t exist in Sonarqube, but when would you ever want it to constantly update the project name on every scan?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [February 6, 2024, 6:05pm UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842/4 "2024-02-06T18:05:05Z")

</div>

Hi,

Welcome to the community!

> [@Erik\_Vickroy](#):
>
> Just to confirm, it sounds like when using the Sonar Scanner for Maven, there is no way to prevent it from ALWAYS updating the Project Name from the pom file’s “name” element?

To be fair, it’s not usually an update. 🤷‍♀️

Can I ask why you would want a different name in the pom than you actually want people to use as the project’s name?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![Erik\_Vickroy](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/erik_vickroy/32/53943_2.png) [@Erik\_Vickroy](https://community.sonarsource.com/u/Erik_Vickroy)\
**Post date:** [February 6, 2024, 7:27pm UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842/5 "2024-02-06T19:27:44Z")

</div>

Our applications/products have well formed names that are reflected in all of our business and developer tools (SCM, Sonarqube, Jira, etc.). Our new application automation uses the Sonarqube API to pre-configure the application’s project name, key, etc. to synch with all of those tools. Everything works great for all other tech stacks running sonarqube scans (.Net, React, Python, Go, etc.) as they do not override the project name that we have already set. Once we hand the application repository over to developers, we have no control over their changes to the pom file. When you have a development team with a mix of internal and external developers, it is very difficult to make them follow standards. We have not had the need to build extra logic to the devops process for creating new repositories to update the “name” field in the pom file to accommodate the issue. We would still have to implement logic to prevent developers from overwriting the values we default it to. The “name” in the pom doesn’t have any relevance since the jar file is named from the artifactid, and there is no pom file packaged with containerized applications that are deployed. If we were building publicly consumed software, it might be different.

---

<div class="post-metadata">

**Author:** ![Erik\_Vickroy](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/erik_vickroy/32/53943_2.png) [@Erik\_Vickroy](https://community.sonarsource.com/u/Erik_Vickroy)\
**Post date:** [February 6, 2024, 7:35pm UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842/6 "2024-02-06T19:35:35Z")

</div>

We were able to workaround it for now, but the developers could still overwrite it. We default the pom file’s “name” element to “${env.CI\_PROJECT\_TITLE}”, which is the environment variable containing the SCM project title in our pipelines.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [February 6, 2024, 8:14pm UTC](https://community.sonarsource.com/t/unable-to-update-project-name-via-sonar-projectname-property/87842/7 "2024-02-06T20:14:31Z")

</div>

Hi,

Thanks for sharing your use case.

I’m glad you worked through this.

&nbsp;  
Ann
