I would like to use bash to determine a variable name by parsing a YAML file for the variable name, and then retrieve the value from a variable group on Azure Pipelines. Is this possible?
In a variable group named, I have MY_VAR_1=MY_VALUE_1 and MY_VAR_2=MY_VALUE_2.
In a pipeline using the AzureCLI@2 task, I parse a YAML file and save the values in a variable.
SECRETS=$(yq r $(Pipeline.Workspace)/helm-chart/common-secrets.yml secrets.[*].keys | sed 's/- //')
I then run a for loop on the variable and use the output in a file.
This works when I run outside of Azure Pipelines with the variables defined.
# TEST VARIABLES
MY_VAR_1="MY_VALUE_1"
MY_VAR_2="MY_VALUE_2"
for i in $SECRETS
do
SECRET_VALUE=$(echo ${!i} | base64)
echo " $i: $SECRET_VALUE" >> secrets.yml
done
What syntax can I use in Azure Pipelines to refer to a pipeline variable in a variable group?
I've tried a few things like using macro expression $($i) which failed with a command not found as bash is trying to run it as a command rather than using a pipeline variable.
secrets.ymlfile.