Step Variable Run Condition only when previous steps succeed

Hi,

Is there a way to use a Step Variable Run Condition, however, also only run the step when previous steps have succeeded?

Hi,

Thanks for getting in touch! While there’s no built-in functionality to allow multiple run conditions like this (only one option can be selected at a time), you can still work around this using nested #{if} conditions within the variable expression condition to depend on multiple conditions.

You can take advantage of the system variable Octopus.Step[StepName].Status.Code and only run when the value equals Succeeded for the single step. This is a workaround, as it depends on only the single step you define, but you could set the condition of that defined step to Success: Only run when the previous steps succeed and you could get the same behavior that way.

Specifically, I was able to get this working using something a variable expression like this:

#{if Octopus.Step[StepName].Status.Code == "Succeeded"}#{if variable2 == "true"}true#{/if}#{/if}

Let me know if this helps, and don’t hesitate to reach out if you have any further questions. :slight_smile:

Best regards,

Kenny

Although Kenneth got me on the right path it didn’t seem to work. With some extra searching I found a better solution here

To run a step only if all previous steps were successful, and based on the truthy value of a variable:
#{unless Octopus.Deployment.Error}#{VariableToCheck}#{/unless}

2 Likes

Hi,

Thanks for following up! I’m sorry my previously mentioned solution didn’t work, but it’s great to hear you have an even better one. Thanks for taking the time to let me know. :slight_smile:

Don’t hesitate to reach out if you have any further questions going forward.

Best regards,

Kenny