We have a internal artifactory repository. At the moment all snapshots will be deployed there. We also want to have a different server with a web interface, and want to copy the to it the created artifacts.
For our builds we use Hudson, but the post-build action "Deploy artifacts to Maven repository" together with scp doesn't work. So there is the question of doing it in some other elegant way. Why isn't maven able to have several distribution repositories? Any ideas?
The nicest thing would be if artifactory would support an (automatic!) incremental export to a standard maven repository after each new deployment.
Artifactory does have an automatic export feature. From the documentation:
Isn't that exactly what you need? To transfer the files, you can either mount a shared directory to the remote server and do the backup there, or do the backup locally and then rsync it.
If you are willing to use a custom plugin, you can configure Maven to deploy to a list of "mirror" locations at the same time as the standard deployment. I'd recommend defining this in a profile so you can control what deployments are mirrored (it might not be appropriate to do this on every build).
To define a new plugin you need to create a new Maven project and specify the POM has packaging maven-plugin:
In src/main/java define a Mojo. The code below declares a "mirror" goal, it takes a list of mirrorRepository items (containing a repositoryId and url) to mirror the artifact deployment to. The plugin uses the same approach to deployment as the maven-deploy-plugin, and takes most of the same parameters.
Note that you still need to define a server in your settings.xml for each repository with appropriate permissions to do the deployment or the build will fail!
The mojo references a MirrorRepository type to encapsulate the repositoryId and url, it is a simple bean:
Here's an example configuration using the plugin. Note all the deploy formats are supported (http, scp, ftp):
I think in Artifactory, by default, it maintains different logical repositories for uploading snapshots and non-snapshots. Using permissions, you can make the snapshot repository visible only to some.
If that is not sufficient, another solution that works with Artifactory 2.0 is to have Artifactory use a MySQL database that does asynchronous replication to another MySQL database, which in turn is being read by a separate installation of Artifactory. If that's too real time, you can simply have two different installations that do updates based on business rules.
I don't think maven supports deploying to multiple repositories for a single profile, but perhaps profiles could change the id and urls of the repository.
Maven Deployment
Then use profiles to pick which repo to deploy to:
Maven profiles