Request to provide the command for octopus deploy step

Hi Team,
Could you please share the variable expression that can be used to execute an step based on the Environment Name, I was able to do this for 1 environment. But I want to use this for multiple environments.

For e.g. Lets say we have 3 environments A,B and C . if the variable expression satisfies contains any one of the environment name then the step should be executed, else the step should be skipped.

Thanks in advance.

Thanks,
Sujesh S

Hi Sujesh,

Thanks for getting in touch! An easier option might be to select the applicable environments to run the step on in the Environments section under Conditions on the step, as shown in the screenshot below.

If that’s not ideal for your setup, a few alternative options might help:

  1. If you have fewer environments in which you don’t want the step to run in, you could use unless instead of if which would shorten the required condition.
  2. You could create a variable in your project with a value of True, scoped only to the environments this step should run in (with a default unscoped value of False), then tie the condition to that variable. During deployment, the variable value will be evaluated based on its scoping, and the run condition to be tied to the truthiness of the value, e.g. #{if Variable}True#{/if}.
  3. Define each environment manually in the run condition in their own separate if blocks: #{if Octopus.Environment.Name == "Environment A"}True#{/if}#{if Octopus.Environment.Name == "Environment B"}True#{/if}#{if Octopus.Environment.Name == "Environment C"}True#{/if} and so on.

I hope this helps, and don’t hesitate to reach out with any further questions or concerns!

Best regards,

Kenny

Thank you for the details. this was very useful.

1 Like

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