Let me write 'if ENV_VAR == "foo"' in circle.yml


#1

Would be great if circle.yml supported the following syntax

test:
  override:
     - some_command
     if ENV_VAR_PASSED_IN == "foo":
        - conditional command 1
        - conditional command 2
     - some_other_command

#2

You can use shell script to achieve that.

custom_shell_script.sh
if [[ "$ENV_VAR" -eq "foo" ]]; then // some command fi

circle.yml
test: override: - bash custom_shell_script.sh


#3

Sure, but then I lose all the nice timing output of top level commands in circle :frowning:


#4

I use multi-line key in YAML without wrapping commands in shell script.

- some_command
- ? |
    case $ENV_VAR_PASSED_IN in
      foo)
        echo "foo"
        ;;
      bar)
        echo "bar"
        ;;
    esac

#5

Thanks @kimh,

That’s effectively the same as the previous answer, just without the script. I’d like to take advantage of Circle’s ability to run commands in parallel in lock-step. In my snippet, I don’t have to repeat the conditional.


#6

i join this request and want to add:

  1. it’s useful for triggered requests for say nightly builds!

  2. i want it and not in script so for example i can run docker for nightly builds but not for regular builds simplifying my regular build.

    machine:
    env[“IS_NIGHTLY”] == “true”:
    services
    - docker


#7