• Home
  • About Us
  • Products
  • Industry
  • Customers
  • Partners
  • Blog

XebiaLabs Blog

 

Deployit Cookbook: Executing a command during deployment

Posted on May 24, 2012 by Hes Siemelink

For a deployment, Deployit calculates the step list based on your model. But what if you want to add an extra step? There are several ways to do this. This cookbook entry will explain a simple case: executing a remote shell command on a server.


In this example we will show how to add a step to log the disk usage using the df command. We will do this using the Command Plugin.

When to use the Command Plugin

As said, you can add a step to the step list in several ways. Choosing the command plugin has the following implications:

  • The command is part of a deployment, so the command must be mapped to the particular hosts you want to run it on.
  • The command must be independent of the environment, since the same package (and command) may be deployed to multiple environments.
  • This approach automatically scales to environments with one or more hosts (i.e. using the Automap button, you get the disk usage of every host in the environment)

Setup

We will assume a simple setup for the PetClinic war, that will be deployed to a Tomcat server. When doing a deployment, we have the following steps.

To monitor the target server's disk, we want to add a step that displays the output of the df command at the end of the step list.

We will add this step in three stages

  1. Use to UI to add a command to the application
  2. Test and refine the command
  3. Add the command to the Manifest file, so it will be packaged for subsequent versions of the application.

We will be adding the command using the Command Plugin. Make sure the command-plugin-X.jaris copied to the plugins folder of the Deployit Server home directory.

Adding the command in the UI

Go to the Repository tab, find the PetClinic-war under Applications, and right click a version to add a new command.

We will name the command 'Log Disk Usage' and issue df -H.

After saving, the command is ready to be used in a deployment!

Testing and refining the command

Go to the Deployment tab and start a deployment of the version you just added the command to. In our case, that would be deploying PetClinic war 1.0 to Tomcat.

Note that the command will be mapped to an Overthere Host, so make sure the environment you deploy to contains the overthere.SshHost (or equivalent) Tomcat is running on.

When doing a deployment, we will see that the step has been added:

Don't start the deployment just yet -- we want to to move the step to the end, so we will see the disk usageafter deployment.

The steps in the step list are ordered by weight. As described in the Steplist section of the Reference manual, plugins contribute steps with order values between 0 and 100. So if we want to move the step to the end of the list, we have to change the order value to 100.

Go to the Repository tab and open the Log Disk Usage command. Change Order to '100' and save. Now redo the deployment and we will see that the step has moved:

When executing the deployment, we will see the output of the df command in the logs:

Adding the command to the manifest

We did our changes in the UI, because it's easier to see what's going on and the development cycle (edit-test-refine) is faster. But now we want to make the changes more permanent, so other versions of the same application can use it as well. We do this by editing the Manifest.MF file, that is used to create the application package DAR file.

NOTE: For extensive coverage on how to create Deployit DARs, see the Packaging Manual

This is how the above example looks like in Manifest format:

Name: Log Disk Usage
CI-name: Log Disk Usage
CI-type: cmd.Command
CI-commandLine: df -H
CI-order: 100

You will need to add this snippet to your Manifest, so the next time you create a DAR package, the Log Disk Usage command is included.

Share

About Hes Siemelink

Hes Siemelink is Product Developer at XebiaLabs.
View all posts by Hes Siemelink →
Tags: Command plugin
Filed under: Deployit Cookbook. Bookmark the permalink.
 
← Prev Post
Next Post →

One Response to Deployit Cookbook: Executing a command during deployment

  1. Andrew Phillips says:
    May 25, 2012 at 2:30 am

    Adding a command to a package is especially suited when the action(s) required are specific to the application or package being deployed – in other words, things you are not trying to do generally for all deployments.

    For such actions, it is really the responsibility of the developer or packager to specify them (since they are specific to the application), and the command-plugin gives you a convenient way to do this.

    Seeing commands in packages also serves as a good indication that there is something “exceptional” going on, so you can also use that to gauge your level of deployment process standardisation.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

How Can We Help?

XebiaLabs USA
  • Live Chat Online
  • Phone:508.983.2515
    508.983.2512
  • 98 N. Washington St.
    Suite 501
    Boston, MA 02114
  • Email:info@xebialabs.com

Blog Authors

Sort by Blog Author
Vincent Partington
CTO
Andrew Phillips
VP of Product Management
Xebia Team

Tags

Agile agile operations Agile Strategy alm Application Deployment Application Lifecycle Management Application Release Automation ARA automation best practices cloud cloudbees Cloud Deployments configuration management Continous Integration Continuous Delivery Continuous Deployment Continuous Deployments Continuous Integration continuous value customization datapower Deployit Deployment deployment automation deployment package Deploy to JBoss. Scale. Deploy to Tomcat Deploy to Weblogic Deploy to WebSphere devops dpadmin DTAP Frameworks ITIL ITSM jenkins Oracle Puppet release automation release management virtual appliance Virtualization websphere Xebia Labs

Archives

  • May 2013 (2)
  • April 2013 (1)
  • March 2013 (3)
  • February 2013 (2)
  • January 2013 (4)
  • December 2012 (1)
  • November 2012 (3)
  • October 2012 (2)
  • September 2012 (1)
  • August 2012 (5)
  • July 2012 (3)
  • June 2012 (1)
  • May 2012 (3)
  • April 2012 (4)
  • March 2012 (1)
  • February 2012 (3)
  • January 2012 (2)
  • November 2011 (6)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (3)
  • July 2011 (1)
  • June 2011 (2)
  • May 2011 (6)
  • April 2011 (2)
  • February 2011 (1)
  • January 2011 (4)
  • December 2010 (3)
  • November 2010 (2)
  • October 2010 (1)
  • August 2010 (1)
  • July 2010 (2)
  • June 2010 (3)
  • March 2010 (2)
  • February 2010 (1)
  • December 2009 (1)
  • November 2009 (1)
  • August 2009 (2)
  • July 2009 (1)
  • January 2009 (1)
  • August 2008 (1)
Copyright XebiaLabs B.V. ©.All rights reserved. Disclaimer
Home| About us| Products| Industry| Customers| Partners| News| Blog