This DevOps Tutorial is Part 3 of my series on Java Project Versioning. Check out the other articles:
- DevOps Tutorial (Part 1): Introduction to Project Versioning with Maven
- DevOps Tutorial (Part 2): Use Maven Release Plugin to Manage Versions
- DevOps Tutorial (Part 4): Continuous Integration
- DevOps Tutorial (Part 5): Parallel Deployment
Now that your build pipeline consistently versions your Maven project, you need a place to store your artifacts which are being produced at the end of this pipeline. These artifacts need to be stored much the same way your source code is stored in your SCM. This ensures access to previously released versions of your product. An Artifact Repository is designed to store your war/jar/ear/etc, and distribute it to fellow developers via Maven, Ivy, or the like, share your artifact with you deployment tools, and generally ensure an immutable history of your released products. An Artifact Repository has many more uses beyond storing the released war files for you project, but that is beyond the scope of this article. For more information on artifact repositories Sonatype, the makers of Nexus, have a nice introduction here (http://blog.sonatype.com/2009/04/what-is-a-repository/#.VTfSdPnF8Ro)
First we need to install an Artifact Repository, my choice for this is Sonatype Nexus. I have written a tutorial on how to install and configure Sonatype Nexus on CentOS 7, or you can follow the Sonatype instructions on their website.
It’s time to change our pom.xml yet again. The distributionManagement section of the pom needs to be updated and pointed to our Nexus server.
Add the credentials of a user which has deploy permissions on the Nexus server. Modify your $MAVEN_HOME/conf/settings.xml file and add the following within the servers tag. I have used the default Nexus username/password for the deployment user.
Now we can perform a release of our war, and it will be stored in Nexus’s release repository. This will allow other developers and system administrators’ access to the war to use as a dependency, or to deploy to a production server.
mvn release:prepare release:perform
In order to download the new artifact “SampleWebApp123-3.01.war” open a browser and go to http://quartz:8081/nexus
Select “Repositories” in the left menu
You can now download any release you have made.
In the next article in this DevOps Tutorial series we will explore how to wrap this entire process up in a Continuous Integration (CI) server.