LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-17-2021, 08:14 AM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Rep: Reputation: 0
Unhappy dot notation error in extracting variable value with jq


I am using the below az cli command to extra values from a variable group

Code snippet as below:

Code:
values=(auth0.client_id auth0.domain auth0.redirect_uri auth0.saml_client_id bff.bffApiAddressSearchUrl bff.bffApiUrl bff.bffOcpApimSubsriptionKey cartUrl)

az pipelines variable-group list --group-name "${compare_spa_env}"

for ptr in "${values[@]}"
do

result=$(az pipelines variable-group list --group-name "${compare_spa_env}" | jq '.[0].variables.'${ptr}'.value')

printf "%s\t%s\t%d\n" "$ptr" "$result" $?

done
My payload consist like below, key value pairs:

Code:
       "auth0.client_id": {
         "isSecret": null,
         "value": "NyFf0Zp2ajrhgwub4PQmbYXB2lf5aeuT"
       },
       "auth0.domain": {
         "isSecret": null,
         "value": "secure-sitenv.digital.temp.com.au"
       },
       "auth0.redirect_uri": {
         "isSecret": null,
         "value": "https://tempdstsitenv.digital.temp.com.au/apps/confirm/#/"
       },
       "auth0.saml_client_id": {
         "isSecret": null,
         "value": "S1D9AEtUvIgwYwHgwHIZWq8udS9Xec1D"
       },
       "bff.bffApiAddressSearchUrl": {
         "isSecret": null,
         "value": "https://sitenv-api.platform.temp.com.au/shared"
       },
       "bff.bffApiUrl": {
         "isSecret": null,
         "value": "https://sitenv-api.platform.temp.com.au/sales/funnel/bff"
       },
       "bff.bffOcpApimSubscriptionKey": {
         "isSecret": null,
         "value": "5a500097d0c14eb6acdc2e39219249ee"
       },
       "cartUrl": {
         "isSecret": null,
         "value": "/cart"
       }
However, I am getting as null when it comes to extracting the values to most if not all:

Code:
+ result=null

I did try and change from [0] to [1] in jq command but still no luck
 
Old 06-18-2021, 01:28 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by sysmicuser View Post
My payload consist like below
Without the whole JSON file it's impossible to say what is wrong. Does just
Code:
az pipelines variable-group list --group-name "${compare_spa_env}" | jq '.[0]'
output what you expect?

Judging from examples in Azure DevOps Services REST API, I'd rather expect the jq query to be something like
Code:
jq .value[0].variables....

Last edited by shruggy; 06-18-2021 at 04:43 AM.
 
  


Reply

Tags
json



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
strange value assignments variable = value, value?? ostrow30 Programming 2 07-24-2011 07:59 AM
difference between value *value and value * value PoleStar Linux - Newbie 1 11-26-2010 03:37 PM
pointer notation vs array notation? pablowablo Programming 5 03-14-2005 12:34 PM
dot and dot dot gag Linux - Newbie 4 10-17-2003 05:57 PM
decimal comma notation conversion to dot? heaslein69 Linux - Software 2 01-25-2002 04:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration