1 of 1 people found this helpful
VAR=`blcli BatchJob executeJobAndWait $JOBKEY`
Yes, if use as above, somtime bladelogic does not capture the values. It might be a bug.
Use commands as mentioned below:
blcli_execute BatchJob executeJobAndWait $JOBKEY
Always use Performance commands to improve the speed of execution and performance of job/
Performance commands are :
Siddu, the change to the performance commands above seemed to have helped in that we have no longer seen the issue of losing the handle to the job; however, I now have incidences where the executeJobAndWait is not waiting, so my script continues processing and checks to see if it had errors or not - "getJobRunHadErrorsById" - which shows it was successful when in fact it was still running and had not completed.
blcli_execute BatchJob executeJobAndWait "$JOB_KEY"
echo RUN KEY is: $RUN_KEY
RUN_ID=`blcli JobRun jobRunKeyToJobRunId "$RUN_KEY"`
echo RUN ID is: $RUN_ID
BATCH_STATUS=`blcli JobRun getJobRunHadErrorsById "$RUN_ID"`
echo BATCH_STATUS is: $BATCH_STATUS
if [ "$BATCH_STATUS" = "true" ]
echo Batch job failed
echo Batch job completed successfully
you should be using performance commands in the whole script... and why are you exiting your script if it's sitll running? why not loop to see if it's running and wait till its done ?
Bill you're correct. I am converting my other commands to performance commands as well. In answer to your question, there is obviously a huge chunk of my script ommited here. Suffice it to say that I need to exit this script if the spawned Batch job fails. The placement of my check for the Batch run status is after method "getJobRunHadErrorsById" which is only hit after the batch job completes - or should be completed if the executeJobAndWait works correctly right?
Are you refering to a loop with method "getJobRunIsRunningByRunKey" ? It wouldn't work for instances when the executeJobAndWait doesn't return a handle (RunKey), so guess I can insert those other methods to obtain the runkey findLastRunKeyByJobKey or something........that should work just fine for a solution in case I lose the Handle.
The major outstanding issue now is blcli JobRun getJobRunHadErrorsById "$RUN_ID". It isn't accurate with the boolean it returns. Yesterday, 2 of 7 runs of the above script this method returned false, when in actuality the batch job failed with errors.