Skip to main content
DevOps icon showing cogs

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

Last Updated Dec 28, 2014 — DevOps Expert

Using Deployment Tags in XL Deploy


XL Deploy's tagging mechanism provides a handy way to control the automated mapping of deployable object to their containers. When your environment has multiple containers of a particular type, and multiple deployables that can map to them, XL Deploy will perform a deployment for each possible mapping. A good example is this: you have two jee.War files in your deployment package, and two GlassFish domains in your environment. This will result in a deployment plan of four steps, as each WAR file is deployed to each domain.

But if you intended that WAR "A" should go to domain1 and WAR "B" should go to domain2, then this is the perfect use case for tagging. Simply place a tag on each deployable and container, and then the artifacts will be deployed accordingly. A tag is nothing more than a text string: "A" and "B" would be perfectly functional in this respect, but of course you'd want something more descriptive. Wildcarding is also possible. Within the XL Deploy GUI, tags are a set of strings under the "Deployment" tab on a container or a deployable. Inside the deployment manifest, tags appear as a series of values in this fashion:
  <jee.War name="TestWAR">
Tagging also comes in handy when working with xl-rules to contribute additional steps to your deployment. Let's use a simple example: we're deploying a cmd.Command script object to two hosts in same environment, and we want to have xl-rules contribute a second script to only one of the hosts. Our hosts here are WAS85ND-host and WAS85SA-host. First, let's define a rule in xl-deploy-server/ext/xl-rules.xml:
<!-- in xl-deploy-server/ext/xl-rules.xml -->
<rule name="demo.addRulesContributedScript" scope="plan">
Next, define a Python script in the location you specified as the planning-script-path.  This script has decision-making logic about what steps to add to the deployment plan.
# xl-deploy-server/ext/planning/
from java.util import HashSet
def containers():
 result = HashSet()
 for _delta in deltas.deltas:
  if (_delta.operation != "NOOP"):
   for mem in deployedApplication.environment.members:
    if str(mem.type) == "overthere.SshHost":
 return result
for container in containers():
  description = "Run rules-contributed script",
  order = 55,
  script = "scripts/demo/rulesContributedScript",
  freemarker_context = {'container' : container},
  target_host = container)
Finally, define the script to be executed, referenced by the script keyword in the context.addStep() method:
# xl-deploy-server/ext/scripts/demo/
echo Running on ${}
Note that here we can use a property of the object we inserted into the FreeMarker context. When we map the deployment we get the two scripts from the cmd.Command objects, one for each host.   And we see the step contributed by our rule as the third step in the step list.  The ordering is controlled by the order value we specified, in this case 55.tags3The correct execution of the script contributed by our rule is confirmed by the output:
Creating path ssh:sudo://vagrant:root@ on host Infrastructure/WebSphere/WAS85ND-host
Processing freemarker template scripts/demo/ to /tmp/ot-20141218T182927390/
Executing /tmp/ot-20141218T182927390/ on host Infrastructure/WebSphere/WAS85ND-host
Running on WAS85ND-host
You can view the complete reference for tagging at

More from the Blog

View more
Ascension Launch Banner
Apr 26, 2022

Get ready for peak performance with’s newest AI-Powered DevOps Platform Ascension Release

Today, is excited to announce our latest AI-Powered DevOps ...
Read More
Jan 24, 2022 Value Stream Delivery for SAFe®: The key to amazing business outcomes

The Scaled Agile Framework (SAFe) is the world’s leading framework for ...
Read More
Dec 09, 2021

How SaaS and cloud-based solutions helped the U.S. Department of Veterans Affairs achieve digital transformation

Modernizing legacy systems was an ongoing goal for the U.S. Department ...
Read More
Nov 29, 2021

Increase velocity and reduce risk with AI and machine learning

Artificial Intelligence (AI) and machine learning (ML) have proven use ...
Read More
Contact Us