Reputation: 6049
I've defined Variable Group
which downloads secrets
from Key Vault
.
Looks like that unlike other variables, secrets aren't set automatically as environment variables.
I've tried using a bash script to take those 'task variables' and set them as environment variables but they were gone by the next task:
export ENV1=$(someSecretTaskVariable)
I'm using npm
task which can't be provided with environment variables via the UI and the yaml is read only.
How should this be done?
Upvotes: 0
Views: 1945
Reputation: 676
If you want to create an environment variable that is passed to subsequent Azure DevOps tasks, maybe try this :
echo '##vso[task.setvariable variable=ENV1]$(someSecretTaskVariable)'
instead of export ENV1=$(someSecretTaskVariable)
Upvotes: 1
Reputation: 72201
I dont think you can do this via UI, but via yaml you would do this:
- task: xxx
env:
ENV1=$(someSecretTaskVariable)
apparently you can do this:
Unlike a normal variable, they are not automatically decrypted into environment variables for scripts. You can explicitly map them in, though.
To pass a secret to a script, use the Environment section of the scripting task's input variables.
seems like with UI you can only do this with scripting tasks
Upvotes: 1