Article 5JVNE Need help with loop and jq

Need help with loop and jq

by
sysmicuser
from LinuxQuestions.org on (#5JVNE)
Hi Linux Guru's,

I need some help with for loop.

End Goal:
To be able to create a variable group by using azure cli

Example:
Code:az pipelines variable-group variable create true --name "Sales.Configuration.Spa ${new_env}" --variable "addressSearchBaseUrl" --value "${from for loop}" "addressSearchSubscriptionKey" --value "${from for loop}" ....Now, my for loop snippet is like below

Code:values="addressSearchBaseUrl addressSearchSubscriptionKey cacheUrl calendarApiUrl checkoutBffApiUrl cpCode"

for ptr in $values
do
echo $ptr
temp=$(az pipelines variable-group list --group-name "${target_backend}"|jq '.[0].variables."${ptr}".value')
echo $temp
echo $?
doneHowever, it gives me error as below:
Code: + for ptr in $values
+ echo addressSearchBaseUrl
addressSearchBaseUrl
++ az pipelines variable-group list --group-name 'Sales.Configuration.Spa automation'
++ jq '.[0].variables."${ptr}".value'
WARNING: Command group 'pipelines variable-group' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
+ temp=null
+ echo null
+ echo 0Above code does not work, However, if I run single command it does work. Wonder why!

Code:az pipelines variable-group list --group-name "${target_backend}"|jq '.[0].variables.addressSearchBaseUrl.value'[/CODE]

Code:"https://testenv-api.platform.companyname.com.au/shared"So basically , when my for loop generate values by parsing using jq, I want to use that value for creation of variable group

Any help would be most appreciated.latest?d=yIl2AUoC8zA latest?i=-jr4BHWoGaU:AjdfwbASKm0:F7zBnMy latest?i=-jr4BHWoGaU:AjdfwbASKm0:V_sGLiP latest?d=qj6IDK7rITs latest?i=-jr4BHWoGaU:AjdfwbASKm0:gIN9vFw-jr4BHWoGaU
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments