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 Apr 19, 2015 — DevOps Expert

Deploy a WAR file to OpenShift with XL Deploy using rules


This article is about performing a Tomcat WAR deployment to OpenShift using XL-Deploy. It makes use of xl-rules and rhc client.

So there are three different ways to publish your java application to OpenShift cloud environment
  1. Using git repo with rhc client and committing code for deployment
  2. Using rhc client(cli for openshift) with rhc deploy command and providing a pre bundled war file
  3. Using Rest APIs
For this article, we'll focus on #2 for building a quick extension using xl-rules. For those of you who want to directly jump into using the extension can refer to the code at releases section, a pre built extension jar file is available for download that can be dropped directly in $XLD_HOME/plugins folder to use the functionality
  • Here's the xl-rule for adding a step for deployment to Openshift for a War file
<rule name="rh.TomcatWARModuleCREATE_MODIFY" scope="deployed">
  • Make the following change in the synthetic.xml
<type type="rh.TomcatWARModule" extends="udm.BaseDeployedArtifact" deployable-type="rh.TomcatWAR" container-type="rh.OpenShiftClient" description="Tomcat WAR for Openshift gear">
 <generate-deployable type="rh.TomcatWAR" extends="udm.BaseDeployableFileArtifact"/>
 <property name="appName" required="true"/>
  • Create a folder XLD_HOME/ext/scripts
  • Create a file under scripts folder called and add the contents
echo "Wrapping ${deployed.file} to tar.gz"
mkdir -p dependencies/jbossews/webapps/
cp ${} dependencies/jbossews/webapps/
tar -cvf ${}.tar dependencies
gzip ${}.tar
rhc app-configure ${deployed.appName} --no-auto-deploy -l ${deployed.container.username} -p ${deployed.container.password}
rhc app-configure ${deployed.appName} --deployment-type binary -l ${deployed.container.username} -p ${deployed.container.password}
rhc app deploy --app ${deployed.appName} --ref ${}.tar.gz -l ${deployed.container.username} -p ${deployed.container.password}
  • Once you do the above, restart the server
  • When you log back in XL-Deploy, go to repository
  • Now create a new infrastructure to a machine that has the RHC Client library installed on it ( RHC tools can be downloaded once you sign up for a free trial with openshift ). You may even try to login that machine and test a deployment manually using rhc client
  • You have to ensure that the user you're connecting with should have rhc client available for use and they have performed rhc setup with their openshift username and password so that they can easily deploy applications
  • Now once you test the connectivity for the overthere connection to remote machine, then right click and create a new container of type rh.OpenShiftClient. Provide your openshift credentials for the rhc client connectivity
  • Add the infrastructure to a new environment
  • Under application, create a new application and then a deployment package 1.0. Under that you can create an artifact of type rh.TomcatWAR and upload a sample war file available
  • Now start a new deployment and drag-drop the deployment package and environment.
  • On opening plan analyzer, you can see a step that appears for deployment of war file to the openshift environment
As you can look above in the script, the war file is copied to a temporary location, then it creates a predefined folder hierarchy as mentioned by red hat docs. It then copies the war file under the right folder and bundles everything in tar.gz. It takes the property appName of deployed for the name of the application

More from the Blog

View more
Sep 13, 2021

The Expedited Journey of Digital Transformation

Alan Brown, Digital Transformation Advisor at conducts a se ...
Read More
Aug 23, 2021

Is Data Analytics Missing From Your Digital Transformation?

Nearly every major enterprise is already in the process of digital tra ...
Read More
Aug 19, 2021

Creative Ways to Automate Developer Workflows

When an organization begins an Agile or DevOps journey, the process ca ...
Read More
Aug 12, 2021

How Automation Enhances Efficiency and Delivery Speed In a DevOps Environment

When organizations make the decision to move to a DevOps environment, ...
Read More
Contact Us