DevOps Tools for Continuous Delivery in Jelastic Private Cloud. Part 2: Configure Jenkins for App Life Сycle Automation

| July 7, 2015

Today we’ll continue talking about delivery automation of the project in the confines of our blog series about DevOps approach implementation at Jelastic (in case you’ve just joined us, you will need to get acquainted with the first part of this guide - it will give you an insight on what we are up to). In a few words, our goal is to achieve complete automation of an app’s life cycle management during all of its stages and, as a result, being able to fully concentrate on the process of development of new project features, instead of bothering with controlling its further deployments, testing, moving to suitable hardware, etc.


Previously, we’ve prepared a background for this task (different hardware sets assigned to every team, configured Jenkins continuous integration server and a number of scripts for the deployment behavior management) and now we have everything necessary to proceed. Thus, let’s move on and configure the required Jenkins jobs for subsequently combining all of them into a single continuous flow.

Create Jenkins Jobs

We’ll start with configuring a set of jobs, which represents the core of our automation. Each of them will be devoted for a particular operation, required to be run at the corresponding stage of a project’s lifecycle. As a reminder - here is the suggested processes chain:

Create Environment > Build and Deploy > Dev Tests > Migrate to QA > QA Tests > Migrate to Production

We’ll add all these jobs one by one. Herewith, a couple of the initial steps are similar for all of them:

  1. Click on the New item option at the left-hand menu.


  1. In the appeared form, specify the Item name and select the appropriate project type using the corresponding radio button (these settings will be described in detail for each of the jobs below):


Then click OK to proceed to configuration of the appropriate item.

Create Environment

Create Environment - Freestyle project, that creates a new environment according to the specified install script.

Find the Build section, expand the Add build step list and select the Execute shell option there. Then enter the following commands into the appeared field:

echo "run build $(date)" >> /opt/tomcat/demo/build.log

/bin/bash /opt/tomcat/demo/ {dev_user} {password}


  • /opt/tomcat/demo/ - path to the scripts folder, created above (this is the one we use as an example, while you should substitute it with your own path in case it differs)
Note: The same path will be used for all the rest of the jobs, thus we’ll skip this point in the following instruction sections - please, do not forget to specify it within all the corresponding commands
  • {dev_user} - login (email address) of your development team account
  • {password} - the corresponding user’s password


Note: that if your account name contains any special characters, they should be substituted using the URL encoding.

Save to create the job.

Build and Deploy

Build and Deploy - Maven project, that will build your source code and deploy an app by means of the already added Maven node.

Find the Source Code Management section, choose the VCS type of your project (we are using Git repo with a simple HelloWorld app for this tutorial) and specify the Repository URL in the expanded field.


A bit lower, in the Build Environment section, tick the Set environment variables through a file option and type the path to the corresponding file you’ve created for this purpose (at the last step of the configuration instruction for a Jenkins container within the previous guide).


Then, scroll down to Post Steps and click on the Add post build step expandable list, where you need to choose the Invoke top-level Maven targets option.


Among the proposed variants within the Maven Version list, select the one you’ve created during Jenkins configurations (named Maven in our case), and fill in the Goals field with the following command:

clean install jelastic:deploy

Note: This is done because the pom.xml file of our project already includes the Jelastic Maven plugin, designed to automatically deploy the already built .war file to our environment. You can either use the linked guide to adjust your own project’s deployment in the same way or, if you’d like to test the automation itself, just fork our repo and modify the following strings inside the main Maven config file (i.e. the mentioned above pom.xml) according to your data:

  • {dev_user} - login (email address) of the dev user’s account
  • {password} - password for the user, specified above
  • {cloud_domain} - domain name of your Jelastic Platform

Click Save to finish.

Dev Tests

Dev Tests - Freestyle project, that is intended to run the first set of tests, still at the development stage.

Select the Execute shell option within the Build section and state the following commands:

echo "run tests $(date)" >> /opt/tomcat/demo/build.log

/bin/bash /opt/tomcat/demo/


Save to add this job.

Migrate to QA

Migrate to QA - Freestyle project, that will convey the ownership of your environment to the QA team and physically move it to the dedicated set of hardware for them.

Scroll to the Build section, again choose the Execute shell option and enter the following commands  in the appeared field:

echo "run build $(date)" >> /opt/tomcat/demo/build.log

/bin/bash /opt/tomcat/demo/ {dev_user} {password} {qa_user}

/bin/bash /opt/tomcat/demo/ {qa_user} {password} {destination_hn_group}


  • {dev_user} - login (email address) of your development team account
  • {qa_user} - same for the QA team account
  • {password} - the corresponding user’s (specified prior to this) password
  • {destination_hn_group} - an unique name of the hardware set, the migration should be performed to (can be seen at your JCA > Cluster > Regions section)


Save to finish.

QA Tests

QA Tests - Freestyle project, used for running the automated app check-up at the testing stage.

Note: In our case, this job’s configuration is completely similar to the Dev Tests one. However, during the real development process, these sets of tests may vary - in this case you’ll need to specify another dedicated bash script here.


Migrate to Production

Migrate to Production - Freestyle project, similar to the Migrate to QA one, that will transfer the environment ownership from QA to the production team and physically migrate it to the corresponding hardware set.


Great! Everything is prepared now, thus we can check whether our scheme works fine.

Сonsecutive Manual Check-Up

Let’s see how each of our added Jenkins jobs acts. For that, we’ll run them one by one according to the below mentioned flow:

Create Environment > Build and Deploy > Dev Tests > Migrate to QA > QA Tests > Migrate to Production

To execute a particular item, click on the triangle icon next to it and select the Build Now option within the shown context menu:


The progress of processing each job can be tracked either through the Jenkins output (Console Output option at a particular build’s context menu) or by using the appropriate log files within your Jenkins container.

And below you’ll find the list of expected results upon using our scripts:

Create Environment

Wait until the process is finished and check your dev user account.


As you can see, the new environment was successfully created alongside the already running Jenkins project.

Build and Deploy

At this stage Maven node builds the .war file based on the sources,  provided with the VCS repo link.

Note: that on the very first start the required dependencies are downloaded, thus this deployment can take some time.


As a result, your project will be successfully built and deployed to the environment.

Dev Tests

In our example, this job just emulates some activity for the proper workflow representation, but when running the real tests, their results can be seen via the Console Output section (which is accessible through the special menu for the still being handled or the last finished operation).


Our QA Tests results are similar to these ones and could be tracked in just the same way, thus we’ll skip this step below.

Migrate to QA

Wait until the process is finished and log into your QA team account.


You’ll see your environment appeared at its dashboard, being automatically transferred from the dev user’s account (with no manual confirmation required thanks to the script used) and simultaneously physically relocated to the Test hardware (according to the region label, circled in the image above).

Migrate to Production

The final step is delivery of the polished, comprehensively tested and ready-to-use project to the customers.


Similar to the previous migration operation, it is done in two steps: transferring the ownership and moving the project to the corresponding production hardware.

Once we’ve ensured that all of the steps were successfully executed without any errors, the whole process can be further improved through chaining all of the jobs in a single automated workflow. And to make it even more convenient, we’ll use a special jobs’ initiation trigger, that is executed upon every project commit action - this will help to completely exclude the delays dependant on humans and speed up the passing of each new release cycle.

DevOps Approach Automation

As we’ve denoted above, the continuous integration assumes the complete process automation without any manual steps involved. In our case, this will result in creating of a new environment upon every significant change made to your project and with the concomitant checking, that it works as expected and is instantly delivered to the target audience.

So, in order to achieve such a tight integration of the operations, that all together constitutes the DevOps pipeline, let’s combine our jobs into one sequence.

  1. The first element in our chain is Create Environment, thus expand the context menu for it and chose the Configure option.


  1. In the opened frame, scroll down to the end of the page and choose the Build other project option within the Post-build Actions section:


In the appeared field, state the next element of our chain (i.e. Build and Deploy in this case).

  1. Repeat these two steps for all the rest of the jobs (obviously, except the last Migrate to Production one) until you create your cycle. Just to remind, here is our suggested workflow:

Create Environment > Build and Deploy > Dev Tests > Migrate to QA > QA Tests > Migrate to Production

  1. Once the chain is built, the last thing that is left to perform is to define the initiation point of launching our cycle.


For that, firstly you’ll need to get the URL of the Create Environment job scheduler - right-click on the corresponding icon and choose the Copy link address option.

  1. We’ll use the received value for setting the appropriate githook, bound to the commit action. Thus, open settings of your VCS project (placed at GitHub in our case) and navigate to the Webhook section (or the similar one, according to the used repository storage).


Here, you need to:

  • paste the copied link to the Payload URL field
  • choose the application/x-www-form-urlencoded option within the Content type drop-down list
  • remove the Secret (if stated)
  • select the Let me select individual events item at the events’ section and tick the Commit comment line

Finish with the Add webhook button below.

At last, everything is set up and maximally optimized! Now, just commit any change to your project and enjoy the fully automated procedure of the new build processing, that starts from the environment creation and finishes with the already working new application at the production stage.

Stay tuned with Jelastic in order not to miss the next part of the DevOps article series, where we are going to uncover how to achieve even more automation and implement all of the steps above in just a few clicks! And if you’d like to become one of our valuable partners and benefit from the approach described, start by evaluating our demo platform or just register for a free two-week trial period, choosing among dozens of Jelastic installations available world-wide.

Related Articles