determine job results from three steps results

TJ (32 posts)
November 14, 2018 09:09 AM
Accepted Answer

Hi support,

I have a job with three steps. I will consider the job as success as long one of the steps as being executed successfully.

I do not find an option I could conclude the results from three steps.

Can you help me with that?

 

Thanks,

Tracy

 

 

 

Bill Staff (599 posts)
November 15, 2018 06:50 AM
Accepted Answer

One way to handle this is to use a Job Variable that tracks how many steps have succeeded. At the end of the job you check the variable to decide whether the job has succeeded, and set the status based on that. It's a little complicated at the end because the only way to force the job to have a failure status is by using a Response.

Here's one way to do it:

  1. On the Steps page, set the sequence option to "Execute steps in sequence; job continues even if a step fails."
  2. Define a new Job Variable for the job, named "SuccessfulSteps". Set its type to Integer and its value to 0.
  3. For each of the 3 steps you're running, add a new Response with condition "Task Succeeded." Add an "Update a Job Variable" action and configure the action to increase "SuccessfulSteps" by 1.
  4. Add a new step at the end of the job to update a job variable. It doesn't matter what this step does--we just need a simple step here that we can attach a Response to.
    • Configure the step to set variable "JobSucceeded" to "1" (these values don't really matter).
    • Add a Condition to the step so it only executes if Job Variable "SuccessfulSteps" is greater than 0.
    • Add a Response to the step using event "One or more conditions failed".
    • Add an Action to the Response to "Control a Job or Job Step" and select "Set the job's status to failed" for the action to take.

If any of your steps succeeds, the SuccessfulSteps variable will be >0, so the last step will run. It won't do anything useful, but that's fine. The job's status will be Succeeded.

If none of your steps has succeeded, SuccessfulSteps will be 0, so the last step won't run. The Response will be invoked due to the condition failure and will set the job status to Failed.

 

Replies are disabled for this topic.