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 , 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 , 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
    May 03, 2019 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?

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    May 03, 2019 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
    May 03, 2019 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.