You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
29 lines
1.1 KiB
# register_runner.ps1
|
|
# Set-ExecutionPolicy Bypass -Scope Process
|
|
|
|
param (
|
|
[Parameter(Mandatory=$true)][string]$Runner = $(
|
|
Read-Host "Runner name (e.g. pEpSecRunner)" )
|
|
)
|
|
|
|
if ( -not $Runner.endswith("Runner") ) { $Runner = $Runner + "Runner" }
|
|
$ServSuffixCount = 1
|
|
$ServSuffix = ""
|
|
$Env:RUNNER_NAME = "GitLab$Runner$ServSuffix"
|
|
|
|
$PlainPassword = Get-Content -Path "$Env:UserProfile\Documents\GitLab$Runner$ServSuffix.pw.txt" -ea 0
|
|
# | Out-Null
|
|
|
|
$Password = ConvertTo-SecureString -String $PlainPassword -AsPlainText -Force
|
|
$User = Get-LocalUser "GitLab$Runner$ServSuffix" -ea 0
|
|
|
|
if (! $Env:CI_SERVER_URL) { $Env:CI_SERVER_URL = "https://gitlab.com/" }
|
|
if (! $Env:RUNNER_NAME) { $Env:RUNNER_NAME = $Env:COMPUTERNAME + "-" + $Env:USERNAME }
|
|
if (! $Env:REGISTRATION_TOKEN) { $Env:REGISTRATION_TOKEN = $Env:reg_token }
|
|
$Env:REGISTER_NON_INTERACTIVE = "true"
|
|
|
|
$UserCred = New-Object System.Management.Automation.PSCredential $User, $Password
|
|
|
|
Start-Process -FilePath "C:\Program Files\GitLabCI\gitlab-runner.exe" -ArgumentList ("register", "--executor", "windows-docker", "--config", "C:\Build\GitLab$Runner$ServSuffix\config.toml") -Credential $UserCred
|
|
|