Skip to main content
DevOps Image

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


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
Jul 22, 2021

DevOps as a Service (DaaS): scaling digital transformation the right way

When going through digital transformation, many organizations have dis ...
Read More
Jun 28, 2021

Smash through barriers to data availability, make analytics easier

In DevOps, "data availability" often refers to a state where the app o ...
Read More
Jun 24, 2021

Strategies for DevOps adoption across teams

Implementing DevOps is not merely a change in IT and it’s certainly no ...
Read More
Jun 10, 2021

Desilo DevOps: The power of bringing all your tools and data into one view

When discussing value stream management (VSM), our resources talk a lo ...
Read More
Contact Us