I recently needed to move build artifacts from JFrog Artifactory to Sonatype Nexus. But I couldn’t migrate every project in one go and they were all commingled in the same repository.
The first task was to export the existing artifacts using the built-in utility. Start by navigating to the Admin menu and selecting Repositories under the Import & Export section. I used the following settings. Note that excluding the metadata is important here as they are meaningless to Nexus and will just clutter things up.
The next step was to find a way to filter the uploaded artifacts. I started with
mavenimport.sh script by DarthHater but found that it didn’t meet my
needs. With that inspiration it was pretty easy to create my own
import.sh takes the following options:
-r|--repo-url: the URL of the Nexus repository which the artifacts should be uploaded to.
-u|--username: the username of the account on the Nexus server to use when authenticating the upload. If not specified the default value is
-p|--password: the password of the account on the Nexus server to use when authenticating the upload. If not specified the default value is
-g|--group: the group whose artifacts will be uploaded. This must be specified in dot separated notation. For example,
-b|--base-dir: the directory to search in for artifacts. If not specified the default value is
Using this I can now import just the artifacts I want.
cd /tmp/repositories/ wget https://www.steventwheeler.com/assets/article_files/2018-10-30-migrate-artifactory-to-nexus/import.sh chmod +x import.sh ./import.sh --repo-url https://nexus.example.com/repository/maven-hosted-releases/ --group com.example.myapp --base-dir libs-release-local/