Unable to update sonar project name

Hi ,

I am trying to update sonar project name but unable to find any option in administration . I have also tried updating using api using existing key but it fails with error {“errors”:[{“msg”:"Could not create Project, key already exists:

Is there any way to update sonar project name of existing project ?

Sonar version : * Enterprise Edition

  • Version 7.9.1 (build 27448)

Hi,

only the sonar.projectKey may be changed via web ui project administration.
Changing the sonar.project.name is simply done by changing the sonar.projectName
in the next analysis for an existing Sonarqube project.
Otherwise there is a hack via accessing the Sonarqube database directly and changing the
projectname(s) - had to do that once for a bulk operation.
But as usual the database should be handled as a black box.

Gilbert

1 Like

Hi Gilbert,

Thank you for response,

I have tried using sonar.projectName is command but dont see the project name getting updated in UI after successfull run also .

Hi,

how do you run your analysis, CLI scanner, Jenkins … ?

Hi Gilbert,

We run as part of jenkins pipeline .

Below is the command we run in jenkins.

mvn sonar:sonar -Dsonar.host.url={SONAR_URL} -Dsonar.projectName="S.A.{PROJECT_NAME}" -Dsonar.projectKey=company:{PROJECTKEYName} -Dsonar.login="{SONAR_TOKEN}"

Hi,

so what happens if you use
mvn sonar:sonar -Dsonar.host.url={SONAR_URL} -Dsonar.projectName="S.B.{PROJECT_NAME}" -Dsonar.projectKey=company:{PROJECTKEYName} -Dsonar.login="{SONAR_TOKEN}"

The project name should change from S.A.{PROJECT_NAME} to S.B.{PROJECT_NAME}

Hi Gilbert,

In this case , existing project name is sample-service which need to be updated to S.A.NEW-SAMPLE-SERVICE but after analysis the project name will remain as sample-service.

Assumed using -Dkey=value with mvn cli and sonar:sonar would work as usual, but in fact
i never used it. We have generic Jenkins pipelines provided as shared library where users are
not able to change the mvn commandline, all configuration is done via pom.xml and a pipeline.yaml file.

The docs https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/
don’t mention -D at all and https://docs.sonarqube.org/latest/analysis/analysis-parameters/ has

sq_mvn

Did a quick test with tree/master/sonarqube-scanner-maven/maven-basic of

and used

<name>Example of basic Maven project</name>
      <properties>
        <sonar.projectName>foobar</sonar.projectName>
        <revision>${env.BUILD_NUMBER}-SNAPSHOT</revision>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!--<maven.compiler.release>11</maven.compiler.release>-->
      </properties>

and it works as expected
sq_mvn_dashboard

1 Like

Using the parameter worked for me in pipeline .
-Dsonar.projectName=“PROJECT_NAME”

Thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.