CircleCI Ideas

Using ENVIRONMENT VARIABLE at conditional steps.

steps:
    - when:
        condition: ${CONDITION_BUILD}
        steps:
            - 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
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    23 Jun 07:33pm

    I need this because we use forked repositories to manage access control to sensitive secrets as we're a BitBucket organization and can't use context security and we need the ability to vary which build steps run based on the fork (which could be set in environment variables).

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    4 Apr, 2019 09:51pm

    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).

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    4 Apr, 2019 06:50pm

    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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    4 Apr, 2019 06:42pm

    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?