Repository navigation
Add gh variable get command #9103
Description
Activity
- addedgh-variablerelating to the gh variable commandrelating to the gh variable command
on May 21, 2024 Thanks for the enhancement request. It seems like an obvious addition, I wonder why it wasn't there to begin with. However, no one has asked for it! It looks like in one of the original PRs for the
gh variable listcommand it was possible to filter by name, but I can't find any place that this was discussed for removal.Can you describe your use case a little bit more? It's useful to us to know how people are using the CLI commands to help us understand the bigger picture.
Reacted by Arne Jørgensen- addedmore-info-neededMore info needed from user/contributorMore info needed from user/contributorand removedneeds-triageneeds to be reviewedneeds to be reviewed
on May 21, 2024 Can you describe your use case a little bit more? It's useful to us to know how people are using the CLI commands to help us understand the bigger picture.
We are currently building an internal "starter kit" where we use some shell scripts to set up the individual projects.
These script store some data in variables (e.g., which Jira projects a repository is connected to) and this info is then used by GitHub Action workflows.
It's no problem to set the variables using
gh variable setbut I would like to get them first to make sure we don't override data from a previous run (and to be able to reuse already set data in other scripts).Thanks!
It's no problem to set the variables using gh variable set but I would like to get them first to make sure we don't override data from a previous run (and to be able to reuse already set data in other scripts).
So if I understand correctly there are two outcomes:
- Don't overwrite variables that may have been previously set by other scripts
- Use the value of previously set variables in your script going forward
That makes sense. I wondered whether
gh variable set --no-clobberwould help with1.and be less prone to race conditions, but if you also really need the variables then2.seems worthwhile as well. Thanks for letting me know.In theory, I have race conditions, yes. In practice, probably not.
Both solutions would be useful.
I guess the current lack of a
getcommand could possibly be thatvariableswas based onsecretand there it's most likely by design it has been left out (for secrets it's not listing the values usinglisteither).I guess the current lack of a get command could possibly be that variables was based on secret and there it's most likely by design it has been left out (for secrets it's not listing the values using list either).
Yeh that's my suspicion as well. In the absence of any other obvious reason appearing, this seems like a good addition to me. I'm going to label it
help wantedin case you or anyone else is interested in contributing.Reacted by Arne Jørgensen- addedhelp wantedContributions welcomeContributions welcomeand removedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on May 21, 2024 Ok, I took a stab at it. It's heavily based on the
gh variable listandgh variable deletecommands. I think I managed to keep what was needed and remove unwanted stuff.- added a commit that references this issue
on May 23, 2024 I created #9118 as a follow up on this if you're interested in having a look at it I can point you in the right direction but no worries if you're not interested. Thanks!
Reacted by Arne JørgensenThank you, @williammartin!
I wanted to take a look at #9118 today, but I can see @babakks beat me to it. Thank you, @babakks!
Reacted by Babak K. Shandiz@arnested Sorry, I didn't notice this comment here. I was just looking for
help-wantedissues. By the way, kudos for adding thevariable getcommand.No need to be sorry, @babakks 😄
I didn't really have the time anyway 😄
Reacted by Babak K. Shandiz
Describe the feature or problem you’d like to solve
It's currently possible to set a variable using, e.g.,
gh variable set FOO --body=BAR.And it's possible to list all variables using:
It's not possible, though, to read a single variable using, e.g.,
gh variable get FOO.It is possible to achieve using:
I'm pretty sure I won't be able to remember that command when I need it. And I'm pretty sure it'll require a lot of brain cycles to read and understand it.
Proposed solution
I propose to add a
gh variable get FOO.