When it comes to developing software we should always be striving to deliver quality, and with this we typically will work on projects where we have the need to keep improving or optimising our solution through iterative releases – Agile Software Development. This is when we should really be thinking about some cool tools which will help us to implement a Continuous Implementation / Continuous Delivery process within our team / teams.
This article will provide a quick overview getting up and running with Jenkins. For the purpose of this article I am specifically interested in automating the deployment of a Tomcat application into a Windows Server 2012 environment, and will be looking to deploy a WAR file into Tomcat. I will be using GitHub for my Source Control.
The IDE I will be testing against is Eclipse.
Available from https://jenkins.io/
So Jenkins is an open source automation server, which provides a whole load of plugins to allow you to deploy and automate any typical project. In the scenario I am after, I want to commit my code from Eclipse into source control and deploy my war file automatically.
The Jenkins solution was very simple to deploy, I downloaded the jenkins.war file from the Jenkins website choosing the LTS (Long Term Support) version, and dropped it into my Tomcat webapps directory.
Then I navigated to my new Jenkins installation and went through the configuration, when it came to the plugins installation I just chose the typical configuration.
I then had to connect up to to my GitHub repository within Eclipse to submit my source code and then go through the configuration of my item in Jenkins. I chose the Freestyle Project template as my starting point.
I then had to install Git on my Server instance, and also install Ant.
I also ended up installing an extra plugin named “Deploy to container Plugin” which allowed me to automate the deployment into Tomcat.
After quite a bit of playing with settings and the build.xml I was able to get Jenkins to work on each commit I did to GitHub. I had quite a few failed builds, which I then had to review via the console output to see what caused the failure; these were mainly configuration issues and missing tools.
So this has now enabled me to perform truly agile development, where each commit is being pushed to a live server, in a work environment I could have this set up to goto a pre-production or staging environment before being pushed into a live environment. The possibilities are endless, and from an agile perspective I can now release software at an incredible speed, meaning all I need do now is commit my changes to source control and perform a push to GitHub, and they will be built and deployed onto my server.
Additional Configuration – Automating Git Push’s
I decided that I did not want to be polling on the server for changes in the source control, or be doing periodic build, so I used GitHubs webhooks to allow me to trigger a build from Jenkins directly. I tried the settings in Jenkins to allow the push to be automated from GitHub, however this appeared to have issues. To get round this I used the generic webhook in Github to trigger a build using a token that I created in Jenkins.