4 Replies Latest reply on Oct 10, 2014 9:50 AM by richard mcleod

    Creating an execution task in a folder via BLCLI

    richard mcleod

      Need some guidance here... I'm trying to create an execution task via BLCLI in a specific folder but have been unsuccessful. I've only been able to create an execution task in the folder path of the target job.

       

      #masboc.nsh
      ###################################################################################
      
      
      zmodload zsh/datetime
      
      
      blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true
      
      
      while getopts ":j:" opt;
      do
        case $opt in
        j)
        jobPath="${OPTARG%/*}"
        jobName="${OPTARG##*/}"
        ;;
        \?)
        echo "Incorrect options found!" >&2
        echo "Ensure jobPath flag is set to -j and value is set!" >&2
        exit 1
        ;;
       :)
        echo "Option -$OPTARG requires an argument" >&2
        exit 1
        ;;
        esac
      done
      
      blcli_execute Job getFullyResolvedPropertyValue "BATCH_JOB" "${jobPath}" "${jobName}" "BB_LAST_MODIFIED_DATE"
      blcli_storeenv bJobLastModifiedDate
      
      blcli_execute BatchJob getDBKeyByGroupAndName "${jobPath}" "${jobName}"
      blcli_storeenv bJobDBKey
      
      blcli_execute BatchJob getValueByPropertyString "DATE_MODIFIED"
      blcli_storeenv bJobDateModified
      
      echo "Date_Modified: ${bJobDateModified}\n"
      echo "Last_Modified_Date: ${bJobLastModifiedDate}\n"
      
      if [[ "${bJobDateModified}" > "${bJobLastModifiedDate}" ]]; then
        echo "The Date_Modified is newer than the Last_Modified_Date\n"
        echo "This means that the job has been modified since we last updated schedules!\n"
        echo "We should reset the phasing to be safe\n"
      
        blcli_execute JobGroup groupNameToId "${jobPath}"
        blcli_storeenv parentJobGroupId
      
        echo "parentJobGroupId: ${parentJobGroupId}\n"
      
        etJobPath="${jobPath}/ET"
      
        echo "etJobPath: ${etJobPath}\n"
      
        blcli_execute Group groupExistsByTypeAndName "5005" "${etJobPath}"
        blcli_storeenv etJobGroupExists
      
        echo "etJobGroupExists: ${etJobGroupExists}\n"
      
        if [[ "${etJobGroupExists}" = "False" ]]; then
        echo "The Execution Task Job Group does not exist!\n"
        echo "Creating the following job group: ${etJobPath}\n"
      
        blcli_execute Group createGroupPath "5005" "${etJobPath}"
        blcli_storeenv etGroupCreatedKey
      
        echo "ResultKey: ${etGroupCreatedKey}\n"
        fi
      
        echo "Creating the execution tasks now!\n"
      
        blcli_execute Group groupNameToId "${etJobPath}" "5005"
        blcli_storeenv etJobGroupId
      
        blcli_execute ExecutionTask setGroupId "${etJobGroupId}"
      
        blcli_execute ExecutionTask createExecutionTask "${bJobDBKey}" "${jobName}_ET_1"
        blcli_storeenv et1DBKey
      
        blcli_execute ExecutionTask addTargetGroups "${et1DBKey}" "${TGTGROUP1}"
        blcli_storeenv et1DBKey
      
        blcli_execute ExecutionTask addOneTimeSchedule "${et1DBKey}" "2014-10-10 01:01:01"
        blcli_storeenv et1SchedKey
      
        echo "check the console for the newly created execution tasks!\n"
      
      else
        echo "There is nothing to change!\n"
      fi
      

       

      The setGroupId is throwing the following error

      Command execution failed. java.lang.Throwable: Command Execution Failed: java.lang.Throwable: Command Execution Failed

       

      I assume the ExecutionTask namespace wants me to set the executiontask object first but I can't because its not created yet

       

      You can run this by ./masboc.nsh -j "/path/to/batch/job"

       

      You also need to specify TGTGROUP1="/path/to/server/group" in the script and create a batch job property called BB_LAST_MODIFIED_DATE with the type DATE for it to work