Keep project history when transforming project in module in SONARQUBE - continuous-integration

I recently attempted to change a sonar project into another project module.
I found out in SONAR-4245 that the existing project has to be delete in order to have it in a module.
However, I would like to keep the project history.
Is that possible ?

Unfortunately that's not possible, and we don't plan to make it possible for the moment.

Related

How to update sonar qube project key which contains branch name with slash

We are running sonar qube 7.0 community version. I know where to find the "update project key" feature.
To preserve our project history from years when switching to Gitflow I'm trying to rename the key from groupId:artifactId:origin/master to groupId:artifactId:origin/develop for some projects. But I get an error message which tells me the slash is not an allowed project key character.
Weired: We have many other projects with key groupId:artifactId:origin/develop or groupId:artifactId:origin/feature-xy.
So it looks like it is possible to create a project key with slashes (via maven build with branch.name set) but it is not possible to change a project key to such a value? Really?
Is there any way to get the project key changed? I would even use a solution which changes things directly in the database.
Thanks for help.
As there seems to be no solution from sonar qube we changed the project key directly in the sonar qube database.
Use the following sql at your own risk.
UPDATE projects SET
NAME=CONCAT(NAME, ' origin/master')
WHERE scope='PRJ' AND project_uuid='yourProjectUuid';
UPDATE projects SET
kee=REPLACE(kee, 'yourGroupId:yourArtifactId', 'yourGroupId:yourArtifactId:origin/master'),
deprecated_kee=REPLACE(deprecated_kee, 'yourGroupId:yourArtifactId', 'yourGroupId:yourArtifactId:origin/master')
WHERE project_uuid='yourProjectUuid';
Beware, for maven multi module project you will need some more sql.

How to rename projects in Sonar Qube

I have a few projects which use pom.xmls to run the sonar analysis. Their names are:
Myproject1
Myproject2
Myproject3
Myproject4
I want to rename them on the sonar dashboard:
MyprojectA
MyprojectB
MyprojectC
MyprojectD
whats the simplest way to achieve this? I know that we can update the key, and then on-board the project with the desired name. Is it possible for me to use the same key and update the project display name?
P.S: I use sonarqube version 6.1
I had to eventually change the project name in the settings.xml file. This contained my sonar.projectname and sonar.projectkey. Then, I had to onboard the app on the sonar dashboard with the new details and run the analysis. However, i still feel that a simple renaming feature could have been easy.
Since it is more of an enterprise version of sonar we are not allowed to upgrade the sonar version immediately.

Sonar refuses to analize multimodule project

I have upgraded from Sonar 5.3 to 6.2 and a project X is giving me some weird errors at the sonar stage of the jenkins job (altough build finishes as STABLE).
The project is a standard multimodule maven java project.
Entering the project dashboard a single message appears on screen:
"No analysis has been performed since creation. The only available
section is the configuration."
But in the upper-right corner the red "FAILED" tag shows up. That leads to the Background tasks of the project and there is the failed task with this error log:
The project "com.foo:bar-submodule-1" is already defined in SonarQube
but not as a module of project "com.foo:bar". If you really want to
stop directly analysing project "com.foo:bar-submodule-1", please
first delete it from SonarQube and then relaunch the analysis of
project "com.foo:bar"
I do not want to delete the project and lose the historical data.
So the question is: How can i add a project Y (that is a submodule of project X but Sonar does not recognize it) as a submodule of project X?
EDIT 1
The parent project is the only one that has been analyzed through jenkins jobs.
Your problem is not that Sonar can't figure out your submodules, but the root issue is that there is another project/module with the same name conflicting with the project you are analyzing now. It happens, for example, when you extract a submodule as a standalone library and moves it as a root project and try to analyse the new project. Since it is a new project, but sometime in the past you had another project/module with the exact same name, it won't be able to finish the process. I have found three ways to fix this:
Delete the old project, if it is possible
This is a option that I use when I have analysed mistakenly new projects (with wrong parameters for example) or when I am migrating servers and still have some wrong configuration in place. You can do this in the project's Configuration/Administration menu, 'Delete project'.
Rename the old projects keys
This is my default option, since usually what I want is just keep the old analyses data for old submodules that we are moving to other projects or promoting to root modules. You can do this in the project's Configuration/Administration menu, 'Update key' option.
Updating your current project's keys
This option I use when the submodules conflict with other valid submodules (It can happen when you have different teams creating small libraries that happen to have the same keys). You can do this in two steps. First you need to update your project's keys following the option 2. The next step is to go to your project and update the modules and submodules names using the key sonar.moduleKey. The default value for this is : similar to sonar.projectKey, as especified here. Following these steps you won't lose all your records and old analyses.
I hope it helps.

How to delete a project in SonarQube 5.3 if the search doesn't find it?

A few projects' analysis is failing with the following error:
org.sonar.api.utils.MessageException: Validation of project failed:
o The project "com.xxx.myproject:myproject-api-test" is already defined in SonarQube but not as a module of project "com.xxx.myproject:myproject". If you really want to stop directly analysing project "com.xxx.myproject:myproject-api-test", please first delete it from SonarQube and then relaunch the analysis of project "com.xxx.myproject:myproject".
However, I am unable to find the project on the SonarQube frontend, therefore can't delete it.
I have tried browsing directly to what I imagined the URL for that project to be. That worked for one, but I have more projects with this problem and for those a URL is not available.
One more thing: I use multi-module projects.
You need to get into the DB and do it from there. I did have a script on a previous job to fix this issue :(. I think I can explain what happened there without seeing anything in the DB.
You had a multi-module maven project which was running nice and easily.
Someone run a sonar build on one of the submodules. This updated the submodule in Sonar to become a top level module.
Someone deleted the submodule from sonar (UI) which actually doesn't delete it, but marks it as deleted. And this is also the reason why you cannot find it from the sonar UI.
What I remember doing was to
log on the database
find the row describing the top level module
find the row describing the submodule that is giving you trouble
update the row of the submodule to become a submodule (I remember there was a 'type' column or similar) and update the parent id from the step on 2. You might also un mark this as deleted.
I'm sorry that I cannot be of more help with the specific SQL queries.
I'm using sonarqube version 5.1.x and ran into same problem. Executed mvn sonar:sonar on maven sub-module. To fix it, I updated the kee column products table for that project and set the value to :. After that logged in as admin into UI and did a bulk delete. Re-ran mvn sonar:sonar and able to verify the fix.

How clone duplicate existing project in SonarQube

I have one Project in SonarQube with some history and some Confirmed Issues and I need split this project, because of two versions of source code, but I need the history and Issue changes in both projects. How to do this? It is possible somehow clone, duplicate existing Project to another one with different name?
Cloning or duplicating a project is not supported.
You can use the Time machine functionality of SQ to "recreate" the past analyses of the project under another name but it won't recreate the history of changes on issues.

Resources