Skip to content

Instantly share code, notes, and snippets.

@Stephanevg
Last active May 6, 2019 10:42
Show Gist options
  • Save Stephanevg/073a710bf84a663c687fb9a80ad92af9 to your computer and use it in GitHub Desktop.
Save Stephanevg/073a710bf84a663c687fb9a80ad92af9 to your computer and use it in GitHub Desktop.
List all Gitlab variables
Function Get-GitLabCIVariableValues {
$Standardvariables = Get-Variable | ? {$_.Name -like "CI*" -or $_.Name -like "*GITLAB_*"}
#$NonStandardVariables = Get-Variable -Name "RESTORE_CACHE_ATTEMPTS","CHAT_INPUT","CHAT_CHANNEL","GET_SOURCES_ATTEMPTS","ARTIFACT_DOWNLOAD_ATTEMPTS"
$return = $Standardvariables #+ $NonStandardVariables
return $return
}
$FullLocalRepoPath = (Get-Variable -Name CI_PROJECT_DIR -ValueOnly).Replace("/","\")
$CommitMessage = Get-Variable -Name CI_COMMIT_TITLE -ValueOnly
Write-Host "[COMMIT] $($CommitMessage)"
set-location -Path $FullLocalRepoPath
if($CommitMessage -match ".*export_var.*"){
Write-host "[VARIABLES] Exporting Variables"-ForegroundColor Green
$ExportFile = join-Path -Path $BuildPath -ChildPath "CI_Variables.csv"
Get-GitLabCIVariableValues | Select Name,Value,Description| export-csv -path $ExportFile -NoTypeInformation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment