Nexus Tip: Moving Artifacts Between Nexus Repositories


April 14, 2010 By Tim O'Brien

While Nexus Open Source does not have any UI-level support for moving an artifact between two repositories, you can very easily do this by just manipulating the underlying filesystem and reindexing the two hosted repositories. There are a few reasons you might want to use this functionality, maybe you want to support a promotion strategy between two hosted repositories? If this is something you find yourself doing, my first suggestion is that you consider the Staging functionality available in Nexus Professional. If Staging isn’t an exact match for your requirements, this post will detail the process you should follow if you need to move an artifact between two repositories.

The process for moving an artifact between two hosted repositories:

1. While logged in as an admin, bring both the source and destination repository to an “Out-of-service” state by navigating to the repositories list, right-clicking on both repositories and selecting “Put out of service” as shown in the following figure.

2. While the repositories are Out of Service, you can manipulate the underlying storage directory. Each hosted repository has a folder under ${sonatype-work}/storage. To move a particular artifact, or collection of artifacts between two repositories, you would simply move the files between these directories.

3. Once this move has been completed, you can put both repositories back into service, by navigating to the repository list, right-clicking on a particular repository, and selecting “Put in Service” as shown below.

4. Since you changed the underlying storage for this repository, you will want to rebuild the repository metadata *and* reindex the repository. You can do both of these using the same process you used to put the repository back in service. Navigate to the repository list, right-click on the repository and select both Rebuild Metadata and Reindex.

There’s an Easier Option: Nexus Staging

While the method documented in this blog post will work, if you find yourself frequently needing to move artifacts between repositories, you will want to look into Nexus Professional.  Nexus Professional offers a Staging Suite which provides this functionality with an easier and more intuitive interface.  While Staging doesn’t specifically move artifacts between hosted repositories, it provides for the ability to expose “staged artifacts” in a repository group and to either discard or “promote” an artifact to a hosted repository depending on testing and validation.