Step conditions - Only when failed AND variable is true

Hi Guys,

I’m trying to create a step conditions that only runs only when the following conditions are matched:

  1. A previous step has failed
  2. A variable expressions is true

There is no way to combine these conditions inside one step.

Is there a way to maybe check on a system variable that sees if the deployment has failed so I can put this, including my own variable, inside the variable expression? Like

#{DontRunThisStep} && #{DeploymentHasFailed}

Any ideas?

Thanks,

Tim

Hi Tim,

Thanks for getting in touch! While you can create a run condition based on two variables using the syntax #{if Var1}#{Var2}#{/if}, this may be possible using the solution as outlined in the following thread post.

They were doing the opposite, where a step would run conditionally both on a prompted variable == True and on success of previous steps. I haven’t had a chance to give this a test, but it may work on deployment failure using something like #{if Octopus.Deployment.Error}#{PromptedVariable}#{/if}. Let me know if you have any luck with something like that. :slight_smile:

We also have some additional information in our system variables doc page on tracking deployment status.
https://octopus.com/docs/deploying-applications/variables/system-variables#Systemvariables-DeploymentStatusTrackingdeploymentstatus

If you’d like to see the && and || syntax, we have a current UserVoice suggestion to implement this. Feel free to throw it some votes if you’d like to see this alternative to the nested #{if} conditions. :slight_smile:

Let me know if this helps! Don’t hesitate to reach out if you have any further questions.

Best regards,

Kenny

Hi Kenny,

Awesome! This seems to work in my scenario. Thank you for the advice.

I also upvoted the UserVoice to include && and || in the #{if} statement, this will definitely be an improvement!

Thanks again,

Tim

Hi Tim,

You’re very welcome! That sounds good - I’m glad that helped. :slight_smile: Don’t hesitate to reach out if you have any further questions.

Kind regards,

Kenny