13 Replies Latest reply on Apr 4, 2013 6:10 PM by Siddu angadi

    How to Run Job, Wait for Output, Run the Next Job

      One of my coworkers asked me how to run a job, wait for output, then run another job. Thought I'd post it here for future reference.


      There's a few different ways to do it. You could string together a series of BLCLI commands such as "blcli Job listAllByGroup" and "blcli Job execute". Then you could run "blcli JobRun getEndTimeByRunKeyId." Based on the end time, you could run a "blcli Job execute" for the 2nd job.


      But that's a lot of work, and it looks like there's a better solution. There's a single command that will do what we need, as long as the job is a deploy job:


      "blcli DeployJob executeJobAndWait"


      DeployJob : executeJobAndWait

      This command executes a Deploy Job and waits for the job to end before returning.

      Use this command to execute a job unless the job should be scheduled. Because this command does not return until the job completes, it effectively pauses execution of any script running this command.

      This command returns a handle to the job run. It can be used in other commands that need to reference the Deploy Job run.

      Return Type: com.bladelogic.app.service.job.JobRunKey

      Command Input

      Argument Name Argument Type Description

      jobKey com.bladelogic.model.base.keys.DBKey Handle to the Deploy Job to be executed.



      The following example gets a handle to a Deploy Job, executes the job, and waits for the job to end before returning.


      JOB_NAME="Deploy to all Servers"

      JOB_KEY=`blcli DeployJob getDBKeyByGroupAndName "$JOB_FOLDER" "$JOB_NAME"`

      JOB_RUN_KEY=`blcli DeployJob executeJobAndWait $JOB_KEY`