Problem
...
Could you help me with post processing? I would like to emulate an Autosys AutoSys® max_exit_success
. For example, a max_exit_success=10
means that
- 0
...
- signals success,
- > 10 signals failure and
- 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 the a real exit
- >10 : error_state with the a real exit
I tried to change the error_state with a next_state but it dit this did not work. Could you give me a tiphint?This page is currently being edited....
Solution
You can find instructions about handling exit codes on our How to configure the handling of exit codes by jobs page.
Here is another example:
Code Block |
---|
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().set_suspended( true );
break;
case 5 :
// the job is required to have a setback configuration
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.set_state( next_state );
break;
default :
spooler_log.info("order state changed to " + next_state);
spooler_task.order.set_state( next_state );
break;
}
} |
A possible solution in PerlScript could be:
Code Block |
---|
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.' ===' );
} |