CircleCI Ideas

Using ENVIRONMENT VARIABLE at conditional steps.

    - when:
        condition: ${CONDITION_BUILD}
            - checkout


In this case I want to pass "true" or "false" via ENVIRONMENT VARIABLE from Dashboard.

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Apr 4 2019
  • Not planned
  • Attach files
  • Admin
    Nathan Dintenfass commented
    04 Apr 18:42

    We can't use Env Vars in this context because those are resolved at runtime, whereas the `when` clause is resolved during configuration processing. We do plan to introduce pipeline-level variables in config that would you set a single variable either inside of config or when triggering your pipeline via the API, which would solve for some cases of wanting to do this. Can you elaborate a bit on what the scenarios are that would cause you do change this value?

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    04 Apr 18:50

    I have a repo that builds 6 Dockerfiles.
    When I update one of them I'd like to build only this one, without touching the `config.yml`.
    So I thought that setting all 5 dockerfiles to "CONDITION_BUILD_1, _2, ..., _5 = false" and leaving just "CONDITION_BUILD_6 = true" on CircleCI dashboard would be great.
    With this I'd avoid waiting to all the untouched Dockerfiles be built.

  • Admin
    Nathan Dintenfass commented
    04 Apr 21:51

    I'm going to mark this as Not Planned because we don't have a way to do it with Environment Variables, but do know that this kind of dynamism is very much on our mind. We plan to introduce the variables in config I described, and we're also looking at ways to more dynamically set the environment at runtime (for instance, having the ability to run some kind of setup job that would let you dynamically set the config based on the state of your code).