CircleCI Ideas

Define local variables in CircleCI config.yml

I can define environment variables through settings UI, and then use them multiple times in config.yml by "${ENV_VARIABLE_NAME}". However, that's not good for non-sensitive data, as that's a manual step and cannot be checked in into my version control system.

Looks like I can define environment variables in jobs https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-job , which is another workaround. However, it looks like I cannot do the same thing for orb setups.

For example, I have a lot of duplicated strings `ecs-circleci-qa` in this part of the code https://github.com/gitenter/gitenter/blob/aee28c760523977d8c871d54189543d68942ee63/.circleci/config.yml#L177-L212 , and right now seems there's no workaround unless I hard code/repeat it multiple times.

I think the easiest way is to have CircleCI config.yml to support local variables. However, it seems not supported yet.

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • May 3 2019
  • Taking votes
  • Attach files
  • Admin
    Nathan Dintenfass commented
    03 May 16:59

    We plan to introduce top-level parameters in config. It's not quite "local variables", but it would likely get you some of the DRY value you want. Take a look at this doc that is in preview mode - would that solve your use case? https://github.com/CircleCI-Public/api-preview-docs/blob/master/docs/pipeline-parameters.md

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    03 May 17:43

    Yes, it can resolve my problem. Can I use it now for `version 2.1`, or it is still a design doc?

  • Admin
    Nathan Dintenfass commented
    03 May 18:31

    The reality is it's working now, but we haven't yet documented or launched it officially because we reserve the right to change the shape of it when we build out parameterization of triggering via the API. So, if you can accept the risk that one day your config might break and need to be fixed (which, if it happens at all, would happen if we changed something about how this works to accommodate the API) then you can use it today. Otherwise, we'll be announcing it once it's fully supported.