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 Mar 25, 2013 — DevOps Expert

Community Blog: Scripting XL Deploy


Part of the strength of XL Deploy is our growing community of deployment experts. We always want to encourage users to learn, share and connect! In this week's community blog, IT Architect Jan Vermeir walks through how he created a clean up script to sweep out the XL Deploy repository in one go...

Scripting XL Deploy

By Jan Vermeir, IT Architect All I wanted to do was create a number of plugins and examples for XL Deploy using the different techniques available. While working on examples I was frustrated by having to clean up remainders of previous attempts, so following in the footsteps of greater men than my humble self (most notably professor Knuth who created TeX so he could finish writing a series of books on computer science) I first wrote a script to create junk in the XL Deploy repository and then get rid of it in one sweeping go. To try out the examples you’ll need XL Deploy 3.8.4 (the version I used, but I’m quite sure it’ll work fine with other versions as well). I’ve installed the server and cli in a directory referenced by an environment variable $DEPLOYIT_HOME. I’m using *nix style variable and scripts in my examples. If you insist on using Microsoft you can always download Cygwin or change the examples yourself. After checking out the sources and installing XL Deploy, $DEPLOYIT_HOME should contain the following folders:
XL Deploy-3.8.4-server XL Deploy-3.8.4-cli XL DeployBlogs
XL DeployBlogs contains a directory named tools that for now holds no more than a couple of scripts, most notably three scripts named, cleanup.cli and deploy.cli. In src/test you’ll find a dar file I’m using to try out my scripts and plugins (deps.dar was build from another example I hope to explain later, for now it’s not important; all it does is copy some files and print a message to the console). isn’t really a script but a plugin. It is supposed to be placed in $DEPLOYIT_HOME/cli/ext, but that can become rather tedious very quickly if you’re going through lots of versions, so I left the script in the tools directory and created a symbolic link to it so the cli will pick up new versions when it is restarted. Create a link in $DEPLOYIT_HOME/cli/ext:
cd $DEPLOYIT_HOME/XL Deploy-3.8.4-cli/ext ln -s $DEPLOYIT_HOME/XL DeployBlogs/tools/
One more piece of setup is necessary: create two test environments that are required by the scripts in examples I hope to discuss later. Open the XL Deploy client interface and create two environments named ‘localenv’ and ‘AnotherLocalEnv’. They should contain a overthere.SshHost named ‘local’ and ‘AnotherLocalHost’ respectively. I defined both hosts with default settings and a username of ‘XL Deploy’, but the username doesn’t (yet) matter for the examples. It should exist though, so in my case XL Deploy just connects to localhost as user ‘XL Deploy’ to run the scripts. The scripts in cleanup.cli and deploy.cli are no more than convenience wrappers that make it easier to test new versions of the plugin. After some command line input checking all they do is call one of the functions defined in cleanup.cli is used as follows:
$DEPLOYIT_HOME/XL Deploy-3.8.4-cli/bin/ -username admin -password admin -f $DEPLOYIT_HOME/XL DeployBlogs/tools/deploy.cli -- $DEPLOYIT_HOME/XL DeployBlogs/tools/src/test/deps.dar localenv
The command above starts the cli, connects using default credentials, starts the script named in the -f parameter and passes the two parameters following the double dash to the script. To avoid even more typing I created a shell script that does no more than run the command line above. It takes the environment name as a parameter like this: localenv
To call the cleanup script use: deps
Main methods of utils.pyWith all these details out of the way we can discuss the script. is read by the cli when it is started. Each method in the script is available from the cli command line, but there are two main entry points:
def deployApp(fileName, environmentName): def deleteApp(appName):
These are the methods that are called from deploy.cli and cleanup.cli respectively. deployApp is nothing more than a straightforward deployment of an application from a dar file, like explained in the cli guide (climanual.html) you can find in the server/doc/html directory (open the file and search for ‘Performing deployments’). Before it deploys an app from a DAR archive, deployApp calls deleteApp to erase all traces of previously imported or installed versions from each environment. DeleteApp calls undeployApps (see picture below) to find all versions of the app and undeploys them so they can be subsequently deleted by the call to deleteVersions. deleteVersions works like undeployApps: get a list of stuff to delete, loop and delete each version using repository.delete(). If you’re interested in the details you can clone the repo at
git clone git:// DeployBlogs.git cd XL DeployBlogs/ git checkout 94ff4af
The code for this blog is located in the ‘tools’ directory.

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