Problem
I would like to emulate an Autosys max_exit_success
. For example, a max_exit_success=10
means that 0 is SUCCESS, more than 10 is FAILURE and we consider exit codes between 1 and 9 as a warning.
For a job_chain this would mean:
- 0 : next_state with exit 0
- 1-9 : next_state with a real exit
- >10 : error_state with a real exit
I tried to change the error_state with a next_state but this did not work. Could you give me a tip?
Solution
DEAD LINKYou can find instructions about handling exit codes on our Error Handling Pages.
Here is another example:
function spooler_task_after(){ var rc = spooler_task.exit_code; var next_state = spooler_task.order.job_chain_node.next_state; spooler_log.info("INFO: Job has ended with exit code " + rc); switch(rc) { case 0 : break; case 1 : spooler_log.error("suspend order"); spooler_task.order.suspend = true; break; case 5 : // hier muss am Job ein Setback konfiguriert sein. spooler_log.error("setback order"); spooler_task.order.setback(); break; case 10 : spooler_log.warn("INFO: Please check results and content, REPORT MAY BE AFFECTED"); spooler_log.info("order state changed to " + next_state); spooler_task.order.state = next_state; break; case 15 : spooler_log.warn("INFO: Please check results and content. THERE ARE REJECTS"); spooler_log.info("order state changed to " + next_state); spooler_task.order.state = next_state; break; default : spooler_log.info("order state changed to " + next_state); spooler_task.order.state = next_state; break; } }
A possible solution in PerlScript could be:
if ($spooler_task->params->var("max_exit_success")>0) { my $max_exit = $spooler_task->params->var("max_exit_success"); $spooler_log->info( " Max exit success : $max_exit" ); if ($spooler_task->exit_code == 0) { $spooler_log->info( "--> SUCCESS "); } elsif ($spooler_task->exit_code > $max_exit) { $spooler_log->info( "--> ERROR "); $spooler_log->info( "Error state : ".$chain_node->error_state ); } else { $spooler_log->warn( "--> WARNING "); $spooler_log->info( "Next state : ".$chain_node->next_state ); $order->LetProperty( 'state', $chain_node->next_state ); } $order->LetProperty( 'state_text', '=== Exit code '.$spooler_task->exit_code.' ===' ); }