XebiaLabs | Continuous Delivery and Agile DevOps Tools

XebiaLabs Blog

Subscribe to XebiaLabs Blog: eMailAlertsEmail Alerts
Get XebiaLabs Blog via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Related Topics: Intel XML, XML Magazine

Blog Feed Post

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 https://github.com/xebialabs-community/xld-openshift-plugin

Under 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 deploy-artifact.sh.ftl and add the contents
echo "Wrapping ${deployed.file} to tar.gz"
mkdir -p dependencies/jbossews/webapps/
cp ${deployed.file.name} dependencies/jbossews/webapps/
tar -cvf ${deployed.name}.tar dependencies
gzip ${deployed.name}.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 ${deployed.name}.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 deploy-artifact.sh.ftl 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

The post Deploy a WAR file to OpenShift with XL Deploy using rules appeared first on XebiaLabs.

Read the original blog entry...

More Stories By XebiaLabs Blog

XebiaLabs is the technology leader for automation software for DevOps and Continuous Delivery. It focuses on helping companies accelerate the delivery of new software in the most efficient manner. Its products are simple to use, quick to implement, and provide robust enterprise technology.