Get-GitHubVariable¶
SYNOPSIS¶
Retrieves a variable from GitHub based on the specified scope.
SYNTAX¶
Environment¶
Get-GitHubVariable -Owner <String> -Repository <String> -Environment <String> [-Name <String>]
[-IncludeInherited] [-All] [-Context <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
Repository¶
Get-GitHubVariable -Owner <String> -Repository <String> [-Name <String>] [-IncludeInherited] [-All]
[-Context <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
Organization¶
Get-GitHubVariable -Owner <String> [-Name <String>] [-IncludeInherited] [-All] [-Context <Object>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION¶
Gets a variable from GitHub, which can be at the organization, repository, or environment level.
This function determines the appropriate API call based on the provided parameters.
Authenticated users must have the required access rights to read variables.
OAuth tokens and personal access tokens (classic) need the repo
scope for repositories,
admin:org
for organizations, and collaborator access for environments.
EXAMPLES¶
EXAMPLE 1¶
Get-GitHubVariable -Owner 'octocat' -Name 'HOST_NAME'
Output:
Name : HOST_NAME
Value : github.com
Owner : octocat
Repository :
Environment :
Retrieves the specified variable from the organization level.
EXAMPLE 2¶
Get-GitHubVariable -Owner 'octocat' -Repository 'Hello-World' -Name 'GUID'
Output:
Name : GUID
Value : 354aa0b0-65b1-46c8-9c3e-1576f4167a41
Owner : octocat
Repository : Hello-World
Environment :
Retrieves the specified variable from the repository level.
EXAMPLE 3¶
Get-GitHubVariable -Owner 'octocat' -Repository 'Hello-World' -Environment 'dev' -Name 'DB_SERVER'
Output:
Name : DB_SERVER
Value : db.example.com
Owner : octocat
Repository : Hello-World
Environment : dev
Retrieves the specified variable from the environment level within a repository.
EXAMPLE 4¶
Get-GitHubVariable -Owner 'octocat'
Output:
Name : MAX_THREADS
Value : 10
Owner : octocat
Repository :
Environment :
Name : API_TIMEOUT
Value : 30
Owner : octocat
Repository :
Environment :
Retrieves all variables available at the organization level.
EXAMPLE 5¶
Get-GitHubVariable -Owner 'octocat' -Repository 'Hello-World'
Output:
Name : LOG_LEVEL
Value : INFO
Owner : octocat
Repository : Hello-World
Environment :
Name : FEATURE_FLAG
Value : Enabled
Owner : octocat
Repository : Hello-World
Environment :
Retrieves all variables available at the repository level.
EXAMPLE 6¶
Get-GitHubVariable -Owner 'octocat' -Repository 'Hello-World' -Environment 'staging'
Output:
Name : CACHE_DURATION
Value : 3600
Owner : octocat
Repository : Hello-World
Environment : staging
Name : CONNECTION_RETRIES
Value : 5
Owner : octocat
Repository : Hello-World
Environment : staging
Retrieves all variables available in the 'staging' environment within the repository.
PARAMETERS¶
-Owner¶
The account owner of the repository. The name is not case sensitive.
Type: String
Parameter Sets: (All)
Aliases: Organization, User
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Repository¶
The name of the repository without the .git extension. The name is not case sensitive.
Type: String
Parameter Sets: Environment, Repository
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Environment¶
The name of the environment.
Type: String
Parameter Sets: Environment
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Name¶
The name of the variable.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: *
Accept pipeline input: False
Accept wildcard characters: True
-IncludeInherited¶
List all variables that are inherited.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-All¶
List all variables, including those that are overwritten by inheritance.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Context¶
The context to run the command in. Used to get the details for the API call. Can be either a string or a GitHubContext object.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-GitHubContext)
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
GitHubVariable[]¶
NOTES¶
An object or array of objects representing the GitHub variable, containing Name, Value, Owner, Repository, and Environment details.
RELATED LINKS¶
https://psmodule.io/GitHub/Functions/Variables/Get-GitHubVariable