Skip steps depending on returncode

GuyS (45 posts)
December 1, 2020 06:10 AM
Accepted Answer

Hello World,

 

I have a job with 9 steps.

Depending on the Exit-code from step 3, which can be 0 or 4, I need the following to happen:

If rc=0, then I want to run steps 4 thru 9, and the whole job is succesfull.

If rc=4, then I want to skip steps 4 to 8 and run step 9, and the whole job is succesfull as well.

 

I've been playing with Responses, Success Criteria, etc. but haven't found the best solution yet.

  • What to use with 'Step Exucution Sequence'?
  • Do I need to let step 3 fail and respond to that by running step 9? What to do with the status of the step and job, which should be succesfull.

 

Any suggestion?

 

Thanks,

Guy Swagten

The Netherlands

 

 

Bill Staff (599 posts)
December 1, 2020 09:34 AM
Accepted Answer

Hi, Guy.

Leave Step Execution Sequence set to the default. For step 3:

  • On the Advanced tab, set the Success Criteria to "Report as successful unless instructed otherwise"
  • On the Responses tab, add a new Response
    • Add an event for "Task completed with the specified result" with exit code = 4.
    • Add an Action to "Control a job or job step." Action to Take is "Run another step in the current job," then select step 9 as the target step.

"Run another step" really should be called "branch to another step," because it transfers control to that step and continues execution from there.

With this setup, if the exit code is anything other than 4, the job executes all steps as normal. If the exit code is 4 it jumps to step 9. In either case, the status of the job is taken from the status of the last step that executes (step 9).

GuyS (45 posts)
December 2, 2020 12:37 AM
Accepted Answer

Thanks Bill...

 

Guy

Replies are disabled for this topic.