2
votes

When I mark an environment variable (Pipeline -> Library) as a secret, I can't seem to access it in my pipeline runs.

For instance, when I try to access the variable, Node.js marks it as undefined.

The following is my import code from the Azure Pipelines YAML file:

variables:
- group: Foo-Bar-Variables

Is there any way for me to access the secret variables? I prefer to not store them as plain-text.

Thank you for your help.

1
@PatrickGoode I would have manually declare each secret variable in my yaml file too?electric_ch

1 Answers

0
votes

Is there any way for me to access the secret variables? I prefer to not store them as plain-text.

Just like the official document Set secret variables, we could to know:

Each task that needs to use the secret as an environment variable does remapping. If you want to use a secret variable called mySecret from a script, use the Environment section of the scripting task's input variables. Set the environment variable name to MYSECRET, and set the value to $(mySecret).

- task: xxxx
  displayName: 'xxxx'
  env:
    SOMEVAR: '$(TestVar)'
  inputs:

Besides, currently, we have to manually declare all the secret variables that we will used in the yaml file.

Hope this helps.