Change the Project Name in SonarQube remotely

Hi Team,

I am using 9.2.3 version of SonarQube Community Edition and scanned some of the projects with sonar-scanner and created the project from it. I want to perform the scan of the same repository and want to change the name of the repository from remotely with Sonar-Scanner and don’t want to create the new project with the new name and instead change the existing project name.

Could you help me on this?

Thanks,
Prasad.

Hey there.

You can change the name of the project by passing a new value to the sonar.projectName analysis parameter when executing a scan.

Hi @Colin

Thanks for your reply. But new project will be created right if we do this and both projects exists now one with OLD name and NEW name.

I want to override name and key of the existing project. is that possible?

Thanks,
Prasad.

The Project Key (the unique identifier for each project) can be adjusted in the project-level Administration > Update Key – that new project key will have to be used anywhere the old project key was used. You still have to update sonar.projectName at analysis time to change the project name (the display name, just for vanity!)

Are you saying this?

  1. The project key has to be changed from the UI as you stated.
  2. Then from the CI tool ex Jenkins, you need to pass the -Dsonar.projectKey=new projectkey -D sonar.projectName=new project name which changes the old project name to new project name as you updated the key via UI and passing new project name from CLI?

My understanding is right?

Can’t override the key as well remotely? because I am getting the project key and project name dynamically from somewhere in code. if we can change it from remote would be helpful for me, will ease my work

Thanks,
Prasad.

Hey there.

Your understanding is right.

Ultimately – SonarQube has to be aware of the changed key so that it makes the connection when the scanner is run… SonarQube can’t guess that the key was changed. So it needs to be updated in SonarQube.

1 Like

Can we rename the project name from the UI?

I have not found this way of changing the project name.

Hi Prasad,

no, the project name can only be changed via analysis property sonar.projectName
or via direct change in the Sonarqube database - which is not recommended, you should
treat it as black box.
I used the DB edit one time for a bulk change after reorganisation where i had to change a LOT of
Sonarqube project names at once.

Gilbert

1 Like