Running a step conditionally

I am sure I’m missing something obvious here.

I have a variable called “color” which is set to blue or green.

I have a step that I want to run only if none of the previous steps has failed and “color” is blue.

I had syntax in the step run condition that said this
#{unless Octopus.Deployment.Error}#{Color == “blue”}#{/unless}

One thing to note and I don’t now if this makes a difference, but there is a possibility that the previous step is skipped.
Step 1 - Succeed
Step 2 - Succeed
Step 3 - Succeed
Step 4 - Skipped
Step 5 - Only run when this there is no error and Color is blue (#{unless Octopus.Deployment.Error}#{Color == “blue”}#{/unless})

But even if there is no error, the step will not run.

What am I doing wrong?

Hi @cqueenan,

Thanks for getting in touch! I did a bit of testing and you should be able to use the following to achieve this:

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

You were close, but something to note about the changes I made. The conditional for evaluating the color to blue requires an IF encapsulation and a result on the successful evaluation (True).

So unless there is a deployment error, and if color is blue, provide the value True in the run condition.

Let me know if this helps. If you have any further question here please don’t hesitate to let me know. :slight_smile:

Best regards,

Thank you!

That seemed to work. I was losing my mind over that syntax!

Hi @cqueenan,

Thanks for the update! I’m glad to hear this worked for you. :slight_smile:

Don’t hesitate to get in touch at any time.

Best regards,

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