Migrating Maven/npm/PyPI Repositories from Nexus to Self-Hosted Repos
Overview
Self-hosted repos allow you to manually upload and download private packages. They can also interconnect with your local development environment to upload and download private packages. For details, see Uploading/Downloading a Private Package.
Uploading numerous packages one at a time can be cumbersome. You can use the migration tool provided by self-hosted repos to upload packages in batches from Nexus or other repositories.
Prerequisites
- You have created a Maven/npm/PyPI repository in the self-hosted repo.
- You have the Python3 environment available.
- If Nexus is used, the migration tool and Nexus must run on the same Linux host and be connected to the CodeArts services network. Python3 must be installed on the host.
Migrating a Maven Artifact
- Find the packages to be migrated from the local Maven repository (for example, C:\Users\xxxxx\.m2\repository) and copy them to a specified directory.
- Go to the self-hosted repo page and select the target Maven repository in the left pane.
- Click the repository name. The Repository Path is displayed on the right. Click
to copy it.
- Click Tutorial in the upper right corner of the page. In the displayed dialog box, click Download Configuration File to download the settings.xml file to the localhost.
Open the file on the localhost and find the username and password.
- Click
in the upper right corner of the page and click Download Migration Tool (uploadArtifact2.py script and artifact.conf configuration file) to the localhost.
- Configure artifact.conf.
artifact packageType = Component type. Set it to Maven. userInfo = username:password (username and password obtained in step 4) repoRelease = Repository URL (Release) (repository URL obtained in step 3) repoSnapshot = Repository URL (Snapshot) (repository URL obtained in step 3) srcDir = Component directory (specified by users), for example, the target directory for storing the downloaded package in step 1. [nexus] nexusAddr = Nexus address nexusPort = Nexus port repoName = Name of the Nexus repository to be migrated userName = Nexus username passwd = Nexus password
- Run the migration script python uploadArtifact2.py.
- Go to the target self-hosted repo and check whether the package is uploaded.
Migrating an npm Package
- Go to the self-hosted repo page and select the target npm registry in the left pane.
- Click the repository name. The Repository Path is displayed on the right. Click
to copy it.
- Click Tutorial in the upper right corner of the page. In the displayed dialog box, click Download Configuration File to download the npmrc configuration file to the localhost.
Open the configuration file on the localhost, find the value of the _auth field, and decode the value using Base64.
- Click
in the upper right corner of the page and click Download Migration Tool (uploadArtifact2.py script and artifact.conf configuration file) to the localhost.
- Configure artifact.conf.
artifact packageType = Component type. Set it to npm. userInfo = Value of the _auth field decoded using Base64 in the npmrc configuration file of the npm registry. (For details, see step 3.) repoRelease = Repository URL (repository URL obtained in step 2) repoSnapshot = Left empty srcDir = Component directory, for example, C:\Users\xxxxxx\repository. You can specify a directory. [nexus] nexusAddr = Nexus address nexusPort = Nexus port repoName = Name of the Nexus repository to be migrated userName = Nexus username passwd = Nexus password
- Check whether the Include Patterns is configured for the target npm registry.
Check whether the private binary package in the package.json file is in the whitelist. Only packages on the whitelist can be uploaded successfully. If no whitelist is configured, all private binary packages in the package.json file can be uploaded successfully.
- Run the migration script python uploadArtifact2.py.
- Go to the target self-hosted repo and check whether the package is uploaded.
Migrating a PyPI Package
- Go to the self-hosted repo page and select the target PyPI repository in the left pane.
- Click the repository name. The Repository Path is displayed on the right. Click
to copy it.
- Click Tutorial in the upper right corner of the page. In the displayed dialog box, click Download Configuration File to download the pypirc file to the localhost.
Open the file on the localhost and find the username and password.
- Click
in the upper right corner of the page and click Download Migration Tool (uploadArtifact2.py script and artifact.conf configuration file) to the localhost.
- Configure artifact.conf.
artifact packageType = Component type. Set it to PyPI. userInfo = username:password (username and password obtained in step 3) repoRelease = Repository URL (repository URL obtained in step 2) repoSnapshot = Left empty srcDir = Component directory, for example, C:\Users\xxxxxx\repository. You can specify a directory. [nexus] nexusAddr = Nexus address nexusPort = Nexus port repoName = Name of the Nexus repository to be migrated userName = Nexus username passwd = Nexus password
- Run the migration script python uploadArtifact2.py.
- Go to the self-hosted repo page and check whether the binary package is successfully uploaded.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot