Skip to end of metadata
Go to start of metadata

 

Assuming, you have a shell script as a member of a job chain. You want to check, whether the call of the script is running after a suspend, that is, the last call ended with an error.

You can achieve this by adding some pre-processing and post-processing to the job.

Setting the default value of an order parameter suspend in the pre-processing

 function spooler_process_before() {
    var order = spooler_task.order;  
    if (order.params.value("suspend") == null){
       order.params.set_var("suspend","false");
    }
    return true;
  }

Checking the exit code. If not zero then set the order parameter suspend to true

 function spooler_task_after(){
    var order = spooler_task.order;
    if (spooler_task.exit_code == 0){
       order.params.set_var("suspend","false");
    }else{
       order.params.set_var("suspend","true");
    }
    return true;
 }

Then the environment variable will be accessible in your script:

 echo ------ %scheduler_param_suspend%

The whole sample can be downloaded here suspend_sample.zip

Write a comment…