Hi,
We are trying to use new feature ‘Run condition variables’.
Is there a way to evaluate the whole expression as true, if it consists of two conditions?
something like
#{if Octopus.Environment.Name == “Production”} AND #{if VariableName == “True”}
or
#{if Octopus.Environment.Name == “Production”} && #{if VariableName == “True”}
Thanks for reaching out! At the moment that is not possible. Feel free to add a uservoice suggestion for it though: http://octopusdeploy.uservoice.com/ . I would go with a subject along the lines of Allow Variable run condition to support many variables and not just boolean values and then explain it a bit more with examples in the description.
For the time being if you want something to only run when in Production and if the variable VariableName is True, you’re gonna have to scope the variable to the Production environment and set the Run Condition to watch for that variable.
@Dalmiro (and anyone needing to do multi-variable conditionals)
I believe there is a way to do this currently. I did some decent testing, as I needed to have a prompted variable to run a step, but I ALSO needed the step to only run if all previous steps were successful.
What I did (based on Octostache documentation) was to use the following:
This allows me to only run on success and with PromptedVariable == True.
In a similar fashion, I tested using multiple prompted variables, such as this:
#{if PromptedVar}#{AnotherVar}#{/if}
And it also worked as expected. Perhaps this is something that should be added to the documentation, as it is INCREDIBLY useful to run conditionals combined with only on success / failure of previous steps.
In my testing, using #{if Variable1}#{Variable2}#{/if} has been working. As long as Variable1 and Variable2 are both ‘true’ then it runs.
Keep in mind, if you’re setting the variables to ‘Y’ then you will need what you have written. If you set them to ‘true’ or ‘false’, there is no need for the == in the evaluation, you can just use #{Variable}.