5

I have linked a variable group to my build pipeline. The variable group has a variable in it. I am trying to use the variable in a bash script in my pipeline.

This document describes how to reference my variable from my variable group:

[https://learn.microsoft.com/en-us/vsts/pipelines/process/variables?view=vsts&tabs=yaml%2Cbatch][2]

However, $TESTING_YOLO does not work.

I have spent 2 hours trying to reference this variable from a bash script. Literally no idea how to do it.

2 Answers 2

4

I have figured out that variables in my variable group that come from key vault are not visible in my env variables when running the bash script.

Further, if I create a variable group that is not linked to key vault i.e. a variable group with key: value, yolo1: yolo1, those variables are visible in my env variables when running the bash script.

To summarise this update, variables in a variable group that come from key vault don't work as expected.

"However, secret variables (encrypted variables and key vault variables) cannot be accessed directly in scripts - instead they must be passed as arguments to a task". Quoted from here: https://learn.microsoft.com/en-us/vsts/pipelines/library/variable-groups?view=vsts

So we had to figure out how to pass arguments to our task. Here I am passing my secret yolo3 as an argument to my bash script task

Pass yolo3 argument to our tasks

Then I can reference the secret yolo3 as an argument in my bash script i.e. $1.

Hopefully, this will help someone else :).

Sign up to request clarification or add additional context in comments.

Comments

3

The format to use the variables from variable group which links Azure key value as below:

$(VariableName)

Such as you can use the format $(yolo). But since the variable yolo is secret, the value will be marked as *** from the build logs.

3 Comments

You are right and I have read something similar in the docs. But, for me, this explanation didn't help me solve my problem. I think it is a bit vague.
Thanks for your input. I updated the question. Let me know what you think.
@jcgh582 Based on the last update in your question, it seems you have already resolved the problem. If so, you can add it in an answer and mark your answer later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.