This article is the second of five in my DevOps tutorial series. In my first article I showed how you can use versioning to concurrently run two versions of a web app on Tomcat. If you missed that part, you can check it out from the list below along with the other parts of this series.
- DevOps Tutorial (Part 1): Introduction to Project Versioning with Maven
- DevOps Tutorial (Part 3): Artifact Management
- DevOps Tutorial (Part 4): Continuous Integration
- DevOps Tutorial (Part 5): Parallel Deployment
In this installment, I’m going to run you through how to use Apache Maven to manage versions of your application.
For this article I assume you still have access to a running Tomcat instance, and a pair of browsers, but now I am adding a source code management (SCM) system to the mix.
Let’s modify our pom.xml again, this time adding the release plugin.
Now we need to connect this project to the SCM, I’m using a GitBlit instance running on the same instance of Tomcat I’m using for testing. If you don’t have an SCM available for testing, see my “Lightning Tutorial – Installing GitBlit”. Add the following to your pom.xml file with the highlighted section matching your configuration.
Next we will add credentials to your SCM server. Add property for project.scm.id, which will reference this id in maven’s settings.xml in $MAVEN_HOME\conf. Add the following to your pom.xml under the project tag:
Add the following to $MAVEN_HOME\conf\settings.xml under the servers tag:
The Maven Release Plugin is designed to store your released artifact, so we need to tell it where to put this artifact. Add the following repository to your pom.xml, with an available directory on your system.
Now we need to add our project to the SCM system.
Let’s do a release
mvn release:prepare release:perform
Answer each of the questions asked during the execution of this command with the default by just pressing the “enter” key.
You will now find a war file under “C:\dev\repositories\releases\com\intertech\SampleWebApp123\1.0”. This war can now be deployed to your tomcat instance.
The next article in this DevOps tutorial series will explain and utilize an artifact management server.
Need more DevOps help? Check out Intertech’s DevOps consulting services.