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 May 31, 2015 — DevOps Expert

Building a XL Deploy DAR Package from properties files/dictionaries/command line arguments

DevOps

This article describes a script which builds a DAR package in XL Deploy from properties which can be specified in and combination of 3 different locations:

  • Properties file
  • XL Deploy dictionary
  • Command arguments
The script is stored as a Gist on GitHub, https://gist.github.com/xlcommunity/92900d63b34528ee14a3This script will create a package with an arbitrary number of artifacts and is useful in situations where a application build process does not feature a tool where there is an existing XL Deploy integration, such as with Jenkins. Optionally, this script can also deploy the package into an environment. Before looking at the script execution, first lets take a look at the properties format. The following example will build a package with 2 artifacts, a WAR artifact and a JBoss datasource.
artifact.type=jee.War
artifact.fileLocation=/Users/tom/qb_repo/builds/17/artifacts/dist/Cars_Sample_App.war
artifact.name=Cars_Sample_App
artifact.tags=['WAR']
datasource.type=jbossas.NonTransactionalDatasourceSpec
datasource.name=Tom_Datasource
datasource.jndiName=jndi/tomsds
datasource.userName={{DB_USERNAME}} datasource.password={{DB_PASSWORD}}
datasource.connectionUrl={{DB_CONNECTION_URL}}
There are a number of items of note the the above example:
  • Keys are always in the format artifactID.property. Where artifactID is a identifier used by the script for each artifact and property is the property to set on that artifact.
  • All artifacts must have a name and type property.
  • When a fileLocation property is set, this must refer to the path of a file on the file system where the script is being executed.
  • When specifing something which is list type in XL Deploy, such as tags, then these must be specified using Python list literal format.
  • Placeholders can be used just as when creating artifacts in the XL Deploy UI.
The above format can be used to specify the properties in a XL Deploy dictionary. The dictionary must be stored in 'Environments/AppDictionaries/<AppName>' by convention. Properties can also be set as a command line argument to the script. When using this approach these properties must be set using Python dict literal format. For example:
"{'webContent.type' : 'www.WebContent', 'webContent.name' : 'myWebContent', 'webContent.fileLocation' : '/Users/tom/scratch/PetPortal_pages.zip'}"
To use the script:
cli.sh -host <XLDeployHost> -username <username> -password <password> -f $ScriptPath/createDar.py -- -n <appName> -b <buildID> -p <propertiesFile> -a <autoDeploy true|false> -e <deployEnv> -x <extraProperties>
For example:
cli.sh -username admin -password deploy -source /Users/tom/Documents/CreateDARCLI/createDAR.py -- -n TestApp -b 1.0-6 -p /Users/tom/builds/propertiesSample.properties -x "{'webContent.type' : 'www.WebContent', 'webContent.name' : 'myWebContent', 'webContent.fileLocation' : '/Users/tom/scratch/PetPortal\_pages.zip'}" -a true -e "MyEnvironment"
This will create a package called "1.0-6", from the build argument, for application "TestApp". It will also deploy this to "MyEnvironment"

More from the Blog

View more
Ascension Launch Banner
Apr 26, 2022

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

DevOps
Today, Digital.ai is excited to announce our latest AI-Powered DevOps ...
Read More
Jan 24, 2022

Digital.ai Value Stream Delivery for SAFe®: The key to amazing business outcomes

DevOps
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

DevOps
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

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