Define local variables in CircleCI config.yml
complete
O
Ozooxo
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.
CCI-I-1020
Liya Ai
Hi all - as a follow-up to Nathan's comment, the team wanted to share that pipeline parameters are now available. More documentation can be found here: https://circleci.com/docs/2.0/pipeline-variables/#pipeline-parameters-in-configuration
s
sumanth thikka
is this official now? can we start using the pipeline parameters?
N
Nathan Dintenfass
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.
O
Ozooxo
Yes, it can resolve my problem. Can I use it now for
version 2.1
, or it is still a design doc?N
Nathan Dintenfass
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