Run condition with variable and previous step success

I’m looking to create a run condition on a Runbook step that will only run if the variable expression evaluates to true AND the previous step succeeds.

I’ve seen other posts about this but they don’t seem to work in for me.

I might have a syntax error so I’ve pasted my exact syntax below.

#{unless Octopus.Deployment.Error}#{IsExistingInstance == “True”}#{/unless}

IsExistingInstance is a prompted drop down variable.

Also, does the Octopus.Deployment.Error piece work with runbooks?

Thanks!

Hi @bneuwirth,

Thanks for getting in touch! Great question, and I did some testing to confirm, and Octopus.Deployment.Error variable does indeed work with runbooks. As far as the syntax goes for multiple conditions like this, I was able to get it working with the following nested if/unless statement, where the condition only evaluates to True when both the prompted variable IsExistingInstance evaluates to True, and previous steps succeed. Either one of those failing causes the condition to evaluate to False.

#{unless Octopus.Deployment.Error}#{if IsExistingInstance == "True"}True#{/if}#{/unless}

Let me know how you go with that, and please don’t hesitate to reach out if you have any questions or concerns going forward!

Best regards,

Kenny

Thanks @Kenneth_Bates

I tried what you had suggested but my runbook is skipping this step whether I check the checkbox of my prompted variable or not.

Hi @bneuwirth,

Thanks for following up so quickly! I’ve given this another test run and it works as expected with a checkbox prompted variable as well in my local instance (running 2020.2.13). Which version of Octopus are you currently running? If it’s older than 2020.2.3 and the prompted variable is scoped to a process (i.e. the runbook), then I would guess you’re hitting this known bug (fixed in 2020.2.3).

If that matches, you’d need to remove the process scoping on the prompted variable, or an upgrade will get it working as is.

If that doesn’t match your scenario, could you send through a verbose task log from a run exhibiting this issue? That should help point us in the right direction.

Best regards,

Kenny

Yes Sir @Kenneth_Bates I am on 2019.12.8

Time for an upgrade.

Thanks!

Hi @bneuwirth,

You’re very welcome! Thanks for confirming, and please let us know how you go or if you have any questions in the future. :slight_smile:

Best regards,

Kenny

@Kenneth_Bates

We just upgraded and your syntax worked.

Thanks!

HI @bneuwirth,

Thank you for following up and confirming that! That’s great to hear it’s working as needed now. If you have any questions or concerns going forward, please don’t hesitate to reach out. :slight_smile:

Best regards,

Kenny

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