Using Environment Variables inside a conditional

Is there a possible way to use an environment variable inside a conditional like this? (code below doesn’t work)

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

I have found the several same questions that was posted years ago but none gave a working solution such as this
and also a feature request here

Hi @stevensim226 - Welcome to the CircleCI community!

It is indeed possible to use parameters in a conditional statement. The correct syntax for the example you shared would be:

- when:
    condition:
      equal: [ true, << parameters.condition_needed >> ]

But in the case of a boolean parameter I would suggest a much simpler syntax:

- when:
    condition: << parameters.condition_needed >>

You can find out more about conditional steps in our documentation.

Hello @yannCI
The problem is that let’s say <<parameters.condition_needed>> is "CONDITION_ONE"
then I have an environment variable $CONDITION_ONE: true

I have an Environment variable (as said in title) whose name is obtained from a parameter. Not just a parameter alone