Content is available under Creative Commons Attribution.


Jenkins Deployment Automation

Creating continuous deployment using Jenkins provides a great free solution for continuous builds, but what about continuous deployment ? Jenkins is a wonderful free tool, which draws a lot of people to it. It’s written in java, which allows you to run the Jenkins server on almost all platforms and it’s a very open-ended allowing you to do pretty much anything you’d like to it.

However… once you’ve spent the time setting up your build jobs, build triggers, data collection, notification schemas, the next logical to step to some folks is: “How do I get this tool to perform my deployments?”

We have seen many customers use Jenkins to setup deployment jobs for the development or maybe even test environments. This is generally done by installing a Jenkins agent on the desired host you want to deploy to and running a shell command from the Jenkins job. Many times these types of deployment are way to simplistic to go beyond the testing environment and people think when they set this up, they have “deployment automation”… but they really don’t. They have a shell script that copies a war file which will not work full life-cycle and requires the target system(s) to be in a particular state which is generally done manually.

Why won’t this work full life-cycle ? What does full life-cycle deployment even mean ?
Full life-cycle deployment means I can automatically deploy my application to all environments from development to production. I am able to do this because the deployment itself considers all relevant aspects of the application and itself (the deployment) is an application that I build and test to ensure it works.. just like any other piece of software. With this level of automation, I need to consider the database changes, configurations and integration points.

How do we do all that ? It seems difficult.
In order to take all these things into consideration, we need a framework that is able to orchestrate the execution of commands and transferring of files in series or parallel expressed as a workflow to an abstract entity we know as an “environment” which is 1 to many hosts each playing different roles. We need to also be able to generate configuration templates that have different values where appropriate for different environments and hosts and be able to easily distribute these configurations to the proper places using automating scripting that returns proper exit codes on success or failure. Leroy allows you to put all these pieces together in an elegant way. First step is to plan the deployment on paper or in plain text, then create the xml to perform the discrete tasks we’ve defined and test it all out on an environment.

How do we put this all together so we are using Jenkins for out deployment automation ?
At the end of the day, Leroy will perform its deployment with one simple command on the command line, it will look something like this:

However, instead of having Jenkins execute this command as a shell step, you can alternatively use the Leroy Jenkins Plugin which provides many nice features and stream-lines the execution of this command for you. One common example is that a user may want to pass properties to Leroy from the build engine to modify how the deployment will change. Common modifications would be boolean options like: CONFIG_ONLY, INITIALIZE, INCLUDE_DATABASE which will alter the behavior of the deployment by using preconditions in your workflow. When we want these options presented in the Jenkins GUI, Jenkins now has to pass these arguments to Leroy on the command line, which would now look something like this:

example of Jenkins deployment automation

The Leroy Jenkins plugin helps you with these properties by giving you additional property types in your job knows as “Leroy Choice”, “Leroy Password”, “Leroy String”. When using these options, these properties are automatically passed to the Leroy command line for you. Additionally, the Leroy Jenkins plugin provides better tracking of where you’ve deployed your components, who deployed it, what you’ve deployed and when. The Leroy Jenkins plugin is free and available on git hub as an open source project and is a great choice for free tooling for developers looking to implement full scale deployment automation.

Leave a Reply

by: Epic Force