Executing a process step based on variable run condition only when previous step successful

In my project I have many process steps (10+) that execute based on a variable run condition, for example:

#{if Octopus.Action[SetDatabaseVariables].Output.BackupBeforeUpgradeFlag}True#{/if}

The problem I am experiencing is that if one of these steps fails, the rest continue to execute. I need them to stop as well?

Is there a way that I can modify this run condition so that it will run if the variable is true and the previous step completed successfully.



Thanks for getting in touch! You can define multiple variable expressions into one run condition, and using the following system variable to retrieve a step’s status can be used for the second part: Octopus.Step[StepName].Status.Code. This variable will return values like Succeeded, Failed, Skipped, etc. as shown in our system variables doc page.

The full run condition expression that worked in my local testing looks like the following: #{if Octopus.Action[StepName].Output.BackupBeforeUpgradeFlag}True#{/if}#{if Octopus.Step[StepName].Status.Code == "Succeeded"}True#{/if}

Let me know if this helps or if you have any further questions going forward. :slight_smile:

Kind regards,


Hi Kenny,
Thanks for the reply.
In my case I need a bit of double negative logic

I have a flag that says to Skip Backup if True. That is, if DisableRoleBackup = True, then do not run the step, otherwise run it.

Using your example, I think I need to subtly change the code to something like:

#{unless Octopus.Action[Step where variable is set].Output.DisableRoleBackup}true#{/unless}#{if Octopus.Step[Previous step].Status.Code == "Succeeded"}True#{/if}

I am hoping this will work.

What I am not sure about is the cascade effect.

What happens if the first step fails, then the next step skips?
That is:

Backup DB -  disable set to **false** so it needs to execute
Backup APP1 - disable variable set to **true**, so it needs to skip
Backup APP2 - disable variable set to **false** so it needs to execute

My thought is that APP2 will not execute because it references APP1 that has been skipped.




Thanks for following up! That run condition looks like it’ll achieve what you’re after. You can set a variable run condition on APP2 to have custom logic to be based on the success/failure of a different step. I.e. instead of calling the status code of Previous step, you can define a different step here to conditionally run based on the status code of a separate step.

I hope this helps! Let me know if you have any further questions going forward. :slight_smile:

Kind regards,


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.