Set project-global environment file in config.yml

In Travis, I can say:

     - BLAH=baz

And BLAH will be set for my entire project, for all jobs, and I can use this to avoid repeating long strings that I need to use in my jobs.

Does CircleCI have equivalent functionality? I checked every occurrence of environment in but they all seem to be under something like jobs/docker; I want my env var to be global. I am also aware I can configure my environment variable in the web UI, but I don’t want to do this: I’d rather have non-public config all in the same place.

I believe the only means to do this now is through the contexts UI – all config-set env variables are step, job, or container specific.

I don’t think it is directly supported, but I believe YAML parsers have to support array merging as part of the spec. I am a bit rusty here, but take a look at the Wikipedia article on it; it’s surprisingly detailed.

What I would try is to define an environment array at the top-level of your YAML document, and then inject it where you need it using the reference symbol. Admittedly it is not quite as tidy as your desired syntax, but at least it is more DRY than repeating the long strings you mention.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.