Help understanding conditional evaluation

Hi,

I have several steps that are gated behind #{if}s. For example, I have a step called “Configure IIS Site WCF Service.” It has a conditional variable expression of:

#{if Octopus.Action[Check for Release Notes].Status.Code == "Succeeded"}#{if dt_InstallAsSite}True#{/if}#{/if}

However, this never executes. I have variable debugging turned on and can’t see Octopus.Action[Check for Release Notes].Status.Code being evaluated or shown anywhere. However, I do see dt_InstallAsSite in the output. In the deployment, I can see my “Check for Release Notes” executing OK. I do see a [Octopus.Action[Check for Release Notes].Output.Octopus.Action.Script.ExitCode] = '0'. Is this what I need to use instead of Status.Code? Are success/failure checks based on the kind of step it is?

What am I missing here?

Hi Michael,

Thanks for getting in touch! This is a great question, as Status.Code only exists under Octopus.Step, which will work if the step you’re checking the status code of is a parent step (i.e. a standalone step or not a child step). Child steps are accessible via Octopus.Action, so the solution would differ depending on what kind of step you’re checking the status of is.

If your Check for Release Notes step is a parent step, then you should be able to get it working by modifying your variable expression to:

#{if Octopus.Step[Check for Release Notes].Status.Code == "Succeeded"}#{if dt_InstallAsSite}True#{/if}#{/if}

However if it’s a child step, which doesn’t have Status.Code, you may need to use Octopus.Action.Status.Error to do something like this:

#{unless Octopus.Action[Check for Release Notes].Status.Error}#{if dt_InstallAsSite}True#{/if}#{/unless}

Does this help get you going? Let me know if you have any further questions or concerns moving forward. :slight_smile:

Best regards,

Kenny

Thank you! That was my problem. To give some feedback, I believe my confusion arose when I clicked on the binding icon to display the current list of variables. All my steps showed up as Octopus.Action[... suggestions instead of Octopus.Step.

Hi Michael,

Thanks for following up and letting me know the result! I can see how that would be confusing, since the variables that are populated in the dropdown from the binding icon are displayed in alphabetical order. Would using the Find... option help in avoiding this confusion in the future?

Best regards,

Kenny

Unfortunately not as that is what I used before. Attached is what comes up when I search for step.

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