Using Environment Variables inside a conditional

Hi @stevensim226,

This can be done using the env_var_name parameter type.

You would need to declare a parameter in your job based on the environment variable:

parameters:
  condition_needed:
    default: CONDITION_ONE
    type: env_var_name

Then you’ll be able to use that parameter inside the when step:

- when:
    condition:
      equal: [ true, "${<< parameters.condition_needed >>}" ]

(Edits: Environment variables always have the type string, so you’ll need to use the above syntax + syntax for env_var_name parameters interpolation)

1 Like