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.
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.