On a MS-hosted Azure pipeline running on ubuntu, within a bash script task, I am setting some pipeline variables that need to be available to another task. These variables are oftentimes maps, in the following format:
{ "1.0.0" = "my-function-app-url.com" }
This will fail the below command, because those maps (stored in the $VALUE
variable, have double quotes, which will be interpreted at the end of the bash script.
echo "##vso[task.setvariable variable=$KEY;isOutput=true;issecret=true]$VALUE"
I have tried to use single quotes to enclose the string being echoed, but the behaviour is the same. I have also tried to escape the double quotes within the variables, but again, the behaviour is the same! I have even tried to remove the quotes, but then the hashtag symbol is interpreted as a bash comment…
Is there a way to achieve what I want here?
2
Answers
You need to add
in the definition of your variables. Refer to the following yaml:
In the log of the first bash task, you can see
##[debug]Processed: ##vso[task.setvariable variable=ValueWithQuotes;isOutput=true]"1.0.0" = "my-function-app-url.com"
.The result of the second bash task:
I have code two samples for setVariable with quotes based on above yml. just have a try and hope this can help.
below is my two results: