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.
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.