Search code examples
bashapigitlabgitlab-api

Access project variable value through Gitlab API


I was able to get the list printed out as in documentation. However I am unable to print only the value of the variable. I am using Bash and I am very new to it, so apologies, if this is stupid question.
My desired output is only the value of variable specified by its key.


Solution

  • From the example provided:

    curl .... | jq '.[] | select(.key=="TEST_VARIABLE_1").value'
    

    Run the curl command and pipe through jq. Select entries where key is equal to TEST_VARIABLE_1 and print only the value entry.