Project move
Project move allows you to export a project from one SonarQube Server instance and import it into another SonarQube Server instance. To use project move, you must have Administer permission rights on the project in the source instance and access to the file systems of both instances.
When you move a project from a source to a target instance, all project data are moved except:
- Source code
- Issue assignments
- Security reports
When to use project move
Project move can help you with the following situations:
- You want to create a central SonarQube Server instance at the enterprise level and you want to keep the history created on instances used previously at the team level.
- You want to consolidate your editions and move projects from a SonarQube Community Build instance to an Enterprise Edition instance or above.
- Your company is acquiring another company that already has a central SonarQube Server instance.
- You are at a large company with several SonarQube Server instances and an application is transferred from one team to another.
Prerequisites
To export your project's data from the source instance and then load it on the target instance, make sure the following are true.
The target instance must:
- Be Enterprise Edition or above.
- Contain all of the plugins with the same versions as the source instance.
The target instance can have additional plugins and languages that aren't in the source instance, but not the other way around. If your source instance has plugins that aren't in your target instance, either remove them and reanalyze your project or add them to your target instance.
Both source and target instances must have:
- The exact same SonarQube Server version.
- The same custom metrics.
- The same custom rules.
You cannot move a project if it has been already analyzed on the target instance.
Step 1: Export the source project to a ZIP file
On the source instance:
- Review the branches of the project by navigating to Project Settings > Branches & Pull Requests and enable Keep when inactive for each branch you want to keep. Note that pull requests are not saved when exporting a project.
- Reanalyze the project one last time for each branch that has enabled the Keep when inactive option to ensure it is populated with data corresponding to your current SonarQube Server installation.
- Navigate to the project and at the project level, choose Project Settings > Import / Export.
- Click on the Export button to generate a ZIP file containing the settings and history of your project (but not the source code). Note that if you need to change the project's key, you must do it before performing the export.
A zip file containing all project data is generated in a file named:
<sonarqubeHome>/data/governance/project_dumps/export/<project_key>.zip
where <sonarqubeHome>:
- For a ZIP installation: is the location where the SonarQube Server distribution has been unzipped.
- For a Docker installation: is the installation directory of SonarQube Server within your container. This path is stored in the SONARQUBE_HOME environment variable.
If the source instance is a Data Center Edition instance, the ZIP file is generated on the application node that processed the export. You have to find out which one to copy the ZIP file from there.
Step 2: Create the target project and import the ZIP file
The procedure is different depending on the target instance edition.
Enterprise Edition
On the target instance:
1. With a user having the Administer System and Create Projects permission rights, go to Administration > Projects > Management and create the project using the same key the project had in the source instance.
2. In the Clean as You Code setup step, select Use the global settings, the project import will take care of importing your former new code configuration.
3. Configure the project's permissions and the quality profiles and quality gate associated with the project.
Do not change anything else on the project's configuration, otherwise the import might not work.
4. Put the generated ZIP file into the directory <sonarqubeHome>/data/governance/project_dumps/import/
(create this folder if it does not already exist).
5. Go to the Project's Home Page and choose Project Settings > Import / Export.
6. Select Import to start importing your data.
7. Monitor the import.
The SonarQube Server application will only read and open ZIP archives with a project key that matches the project key of a brand new, unanalyzed SonarQube Server project. Do not overlook the project key configuration when importing and exporting your project.
If the import is successful, the ZIP file will automatically be deleted.
Data Center Edition
You can use one of the following methods:
Scaling down your target instance to one application node
- Scale down your SonarQube Server instance to one application node:
- Scale in the
-app
deployment to 1 replica only. - Manually update the replica, mounting it to the appropriate sub-directory.
- Scale in the
- Create and import the project on the target instance as explained above for the Enterprise Edition instance.
- Scale the application nodes back up to the desired number.
Importing the file to all application nodes
Proceed as described above for an Enterprise Edition instance but in step 4, duplicate the export ZIP file onto data/governance/project_dumps/import
on all application nodes of the target instance. Then, import the ZIP file as described in the following steps of the procedure.
If the import is successful, one of the ZIP files will automatically be deleted. We recommend that you delete the ZIP files stored on the other application nodes.
Step 3: Trigger an analysis on the moved project
The export ZIP file does not include source code and security reports. Once the import is finished, trigger an analysis to import source files into the new instance and generate security reports.
Was this page helpful?