Gh / Set Organization Variable Visible To All Repos
Set Organization Variable Visible To All Repos
Easily set an organization variable in GitHub to be visible across all repositories with this command.
gh variable set <name> -o <organization> -v all gh variable set <name> -o <organization> -v all #!/bin/bash
# Set Organization Variable Visible To All Repos
gh variable set {{name}} {{[-o|--org]}} {{organization}} {{[-v|--visibility]}} all import subprocess
# Set Organization Variable Visible To All Repos
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"gh",
"variable",
"set",
"<name>",
"-o",
"<organization>",
"-v",
"all"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: gh not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
Setting organization-wide variables for CI/CD pipeline requirements.
Terminal Output
Expected runtime feedback
Variable 'MY_VAR' set to be visible to all repositories in organization 'my-org'.
Visibility: all
Organization: my-org
Variable Name: MY_VAR Power User Variants
Optimized versions
gh variable set MY_VAR -o my-org -v all Set MY_VAR as visible to all repos in my-org.
gh variable set MY_VAR --org my-org --visibility all Set MY_VAR as visible to all repos in my-org using long options.
Troubleshooting
Common pitfalls
Invalid organization name
Solution: Ensure the organization name is correct and you have access.
Variable name already exists
Solution: Choose a different variable name or update the existing one.
Command Breakdown
What each part is doing
-
gh - Base Command
- The executable that performs this operation. Here it runs Gh before the shell applies any redirect operators.
-
<name> - name
- The value supplied for name.
-
-o - o| org
- The value supplied for o| org.
-
<organization> - organization
- The value supplied for organization.
-
-v - v| visibility
- The value supplied for v| visibility.
-
-o - Command Option
- Tool-specific option used by this command invocation.
-
-v - Command Option
- Tool-specific option used by this command invocation.
How To Run
Execution path
- Step 1
Replace {{name}} with the variable name you want to set.
- Step 2
Use -o or --org to specify the organization name.
- Step 3
Add -v or --visibility to set it to 'all'.
Alternative Approaches
Comparable commands in other tools
Alternative version control tools for the same job.
jj split -r <revision> -d <revset> Jj / Split Revision Insert Before After jj split -r <revision> -B <revset> -A <revset> Git / Copy Files Changed In Last Commit To Remote git scp <remote_name> HEAD~1 Git / Copy Specific Directory To Remote git scp <remote_name> <path/to/directory> Git / Create Git Repo Current Directory Commit All Files git setup