pythongitlabcommand-line-interfacegitlab-apipython-gitlab

gitlab CLI - get project variable value


I am basically trying to do this

gl = gitlab.Gitlab('git.mygit.com', private_token='my_token')
gl.projects.get(ID).variables.get('KEY').value

but using CLI commands. I can get to the correct variable, but cannot access the value

gitlab project-variable get --project-id ID --key KEY

I noticed there is --value option in the documentation of gitlab project-variable create, but I can't find a way to access the value of already set project variable.


Solution

  • Just specify the output type (example: json):

     gitlab -o json project-variable get --project-id ID --key KEY