Skip to main content

This post is from the XebiaLabs blog and has not been updated since the original publish date.

Last Updated Apr 19, 2015 — DevOps Expert

Adding Rules To XL-Deploy

DevOps

XL-Deploy uses it's object model to determine it's deployment plan.  For most applications this works fine.  Sometimes we might want to take some extra steps during a deployment.  Custom deployment steps can be created by defining these rules in the XL-Rules file.  Sometimes we may want to dynamically create deployment steps depending on other information in the environment.  As an example of this I will demonstrate how to dynamically create deployment steps with XL-Rules and a small Jython script.   For this example lets say we need to run a script at the beginning and end of our deployment.  We only need to run this script if the infrastructure host has the "pretest" or "posttest" tags set.  Furthermore, we only need to run the script once on each host.  The first step is to define a rule in xl-rules.xmlScreen Shot 2015-03-09 at 4.36.47 PMThe <planning-script-path> tag defines the location of a Jython script that will dynamically create the deployment steps that should be added to the deployment plan.  The path the script starts from is the <XLDeploy_HOME>/ext folder.  Once this file is changed it is necessary to restart the XL-Deploy server for this change to take effect.   Out next step is do define the logic that determines when to add steps to the deployment plan.Screen Shot 2015-03-23 at 4.22.36 PMI have defined the functions to help build our additional deployment steps.  So our script defines the methods then calls update_hosts().  We pass a call to the getContainerListFromDeployedApplicaiton() method to get the unique list of containers we are deploying to.  Then we can go through all of the containers checking for our tags.  If we find the tag set we will add either the pretest step or the posttest step.  For this example our script is the same for both.  The script in this example is a Free Marker Template script.  The result of this script adds some pre deploy steps as well as some post install steps as follows:Screen Shot 2015-04-17 at 1.41.57 PMIt is convenient to use this method for specialized load balancers or kicking off scripted testing from XL Deploy.  You might even find other uses for this. The code in this example can be found in my blog github repository as follows:

   

More from the Blog

View more
Mar 01, 2021

Discover the change management practices that are ripe for optimization

DevOps
Change has become the most important part of modern digital product cr ...
Read More
Feb 22, 2021

Reckoning DevOps’ role in the enterprise value stream

DevOps
If you’re a software or digital solutions company, you may use DevOps ...
Read More
Feb 10, 2021

Customer spotlight: Schneider avoiding bumps in the road with DevOps adoption

DevOps
Everyone wants to deliver software faster and more reliably. Companies ...
Read More
Jan 06, 2021

How testing automation can build a culture of QA while accelerating continuous delivery

DevOps
An organization’s level of automated test coverage is quickly emerging ...
Read More
Contact Us