Home > OS >  How to set or inject an arbitrary file list of environment variables in an Azure Pipeline
How to set or inject an arbitrary file list of environment variables in an Azure Pipeline

Time:03-25

I'm porting some Jenkins builds to Azure Pipelines. One of the port sets involves an arbitrary list of environment variables that constantly changes. In Jenkins I just run an injection script to run on a list file that is within the code base's source and the build references those variables in whatever scripts or build-steps need them. Some of the variables are hard-coded while others reference environment variables of the build itself.

I looked at the enter image description here

CodePudding user response:

The only constant is, I know to look for a root-level file called env-vars.txt

Assuming this is just a list of key:value pairs, you can read them in something like this.

If you don't want to touch the format of the file you could parse it as per @shamrai-aleksander answer and set the variables that way.

variables:
- template: env-vars.yml

env-vars.yml

variables:
somevariable:value
  • Related