Run condition variable expression

Hi All

I have a octopus project where i have 3 steps shown below
image.

Now as you can see 1st step as Dacpac deployement and 2nd step is just retry of 1st step.
I want 3rd step that is master script to run only when either 1 or 2 has passed.
How can i do that? i saw variable expression option in Run condtion for 3 rd step.

Hi Rahul,

Thanks for getting in touch!

Taking a look at your process, the first thing that comes to mind is whether the second step is necessary?
Would it be possible to use Guided Failure to allow you to perform a retry in the event of a failure? Or possibly amend the script in your first step to include a retry loop in the event of an error?

If either of those changes could be made then the Master Script step would be fine being left as the default Success condition.

If that isn’t possible, would I be correct in thinking that the retry step has its Run Condition set to Failure, allowing it to run only when the first step fails?

Assuming that is the case, then a Variable expression that checks the status of the previous steps and only runs if one of them succeeded should work.

e.g.

#{if Octopus.Step[Dacpac Deployments].Status.Code == "Succeeded"}true#{/if} #{if Octopus.Step[Dacpac Deployments - Retry].Status.Code == "Succeeded"}true#{/if}

Regards,

Yes the run condition of retry step is set to failure.

.

However the expression that you provided is always coming as true even if step

  1. Dacpac Deployments and Step 2 Dacpac Deployements - Retry fails.


The expression in 3rd Step is same that you provided.

Well just to be clear , My requirement is if step 1 or step2 is successfull then only step3 should start else should be skipped

Hi Rahul,

Apologies for that, I tested it for each step succeeding and somehow forgot to test for both steps failing.
I’m having some issues finding the right syntax to get this working correctly, so, I’ve reached out internally for some further assistance.

I’ll let you know when I have a solution for you.

Regards,
Paul

Ok, we’ve managed to figure this out.
I was missing an Else statement within the condition.

This should work for you now.

#{if Octopus.Step[Dacpac Deployments].Status.Code == "Succeeded"}
  true
#{else}
  #{if Octopus.Step[Dacpac Deployments - Retry].Status.Code == "Succeeded"}
    true
  #{else}
    false
  #{/if}
#{/if}