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.

28 lines
1.1 KiB

  1. # register_runner.ps1
  2. # Set-ExecutionPolicy Bypass -Scope Process
  3. param (
  4. [Parameter(Mandatory=$true)][string]$Runner = $(
  5. Read-Host "Runner name (e.g. pEpSecRunner)" )
  6. )
  7. if ( -not $Runner.endswith("Runner") ) { $Runner = $Runner + "Runner" }
  8. $ServSuffixCount = 1
  9. $ServSuffix = ""
  10. $Env:RUNNER_NAME = "GitLab$Runner$ServSuffix"
  11. $PlainPassword = Get-Content -Path "$Env:UserProfile\Documents\GitLab$Runner$ServSuffix.pw.txt" -ea 0
  12. # | Out-Null
  13. $Password = ConvertTo-SecureString -String $PlainPassword -AsPlainText -Force
  14. $User = Get-LocalUser "GitLab$Runner$ServSuffix" -ea 0
  15. if (! $Env:CI_SERVER_URL) { $Env:CI_SERVER_URL = "https://gitlab.com/" }
  16. if (! $Env:RUNNER_NAME) { $Env:RUNNER_NAME = $Env:COMPUTERNAME + "-" + $Env:USERNAME }
  17. if (! $Env:REGISTRATION_TOKEN) { $Env:REGISTRATION_TOKEN = $Env:reg_token }
  18. $Env:REGISTER_NON_INTERACTIVE = "true"
  19. $UserCred = New-Object System.Management.Automation.PSCredential $User, $Password
  20. 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