0
votes

I've been trying to store the output of multiple az cli commands in a variable defined in my pipeline with 0 success.

This being my last attempt: enter image description here

The way I try to make sure is getting pass to the var is by doing an echo, which it outputs this(in all attempts): enter image description here

At the end what im trying to achieve is to get the key value stored to use later: enter image description here

Any suggestions on how to do this in the Azure CLI task from Azure DevOps Pipeline?

PS: Have being trying some commands from shell and batch and must of the attempts failures are related to not recognizing commands(batch/shell) inside the script. Which is confusing since in Azure cli task Docs:

enter image description here

Answer

@4c74356b41 Answer helped a lot since I didn't know I could do query in azure cli commands to get a specific value of a command. But it didn't quite answer my questions. All that said, this link Set Output Variable in Azure CLI task on VSTS has the Answer to my question.

1

1 Answers

2
votes

just use query path filtering, something like this:

--query 'properties.properties.sites[0].key' -o tsv

this should output only the key you are interested it. reading:

https://docs.microsoft.com/en-us/cli/azure/query-azure-cli?view=azure-cli-latest