GitLab: Runner (Windows): Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
(GitLab Runner behind a proxy)
 
(6 dazwischenliegende Versionen des gleichen Benutzers werden nicht angezeigt)
Zeile 5: Zeile 5:
 
*Run an elevated command prompt.
 
*Run an elevated command prompt.
 
*Install the Runner as a service and start it. ''You can either run the service using the Built-in System Account (recommended) or using a user account.''
 
*Install the Runner as a service and start it. ''You can either run the service using the Built-in System Account (recommended) or using a user account.''
**'''Run service using Built-in System Account:'''
+
*'''Run service using Built-in System Account:'''
 
  .\gitlab-runner.exe install
 
  .\gitlab-runner.exe install
 
  .\gitlab-runner.exe start
 
  .\gitlab-runner.exe start
Zeile 21: Zeile 21:
 
== GitLab Runner behind a proxy ==
 
== GitLab Runner behind a proxy ==
 
*Add your proxy server in the GitLab Runner configuration "config.toml" (for example):
 
*Add your proxy server in the GitLab Runner configuration "config.toml" (for example):
  concurrent = 8
+
<pre>
 +
  concurrent = 1
 
  check_interval = 0
 
  check_interval = 0
 
  log_level = "warning"
 
  log_level = "warning"
 
   
 
   
 
  [session_server]
 
  [session_server]
session_timeout = 1800
+
  session_timeout = 1800
 
   
 
   
 
  [[runners]]
 
  [[runners]]
name = "<FQDN>"
+
  name = "<FQDN>"
executor = "shell"
+
  executor = "shell"
shell = "powershell"
+
  shell = "powershell"
environment = ["HTTP_PROXY=<your_Proxy>","HTTPS_PROXY=<your_Proxy>"]
+
  environment = ["HTTP_PROXY=<your_Proxy>","HTTPS_PROXY=<your_Proxy>"]
url = "https://<your_GitLab>/"
+
  url = "https://<your_GitLab>/"
token = "<your_token_from_registering_the_runner>"
+
  token = "<your_token_from_registering_the_runner>"
tls_verify = false
+
  tls_verify = false </pre>
 +
 
 
*Add the following Registry-Key to force the GitLab-Runner service to use the proxy:
 
*Add the following Registry-Key to force the GitLab-Runner service to use the proxy:
 
<source lang="powershell">
 
<source lang="powershell">
 
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\gitlab-runner\" -Name "Environment" -Value "HTTPS_PROXY=server-proxy.xaas.swissic.ch:8080" -PropertyType MultiString
 
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\gitlab-runner\" -Name "Environment" -Value "HTTPS_PROXY=server-proxy.xaas.swissic.ch:8080" -PropertyType MultiString
 
</source>
 
</source>
 
 
  
 
== Troubleshooting ==
 
== Troubleshooting ==
 
=== Error: Registering runner... failed runner=xxxx status=couldn't execute POST against..===
 
=== Error: Registering runner... failed runner=xxxx status=couldn't execute POST against..===
'''Error'''
+
'''Error'''<br>
 
''ERROR: Registering runner... failed runner=eGycJT8v status=couldn't execute POST against https://<your_GitLab>/api/v4/runners: Post https://<your_Gitlab>.ch/api/v4/runners: dial tcp <IP>:443: connectex: ''
 
''ERROR: Registering runner... failed runner=eGycJT8v status=couldn't execute POST against https://<your_GitLab>/api/v4/runners: Post https://<your_Gitlab>.ch/api/v4/runners: dial tcp <IP>:443: connectex: ''
 
''A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.''
 
''A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.''
 
''PANIC: Failed to register this runner. Perhaps you are having network problems''
 
''PANIC: Failed to register this runner. Perhaps you are having network problems''
  
'''Cause'''
+
'''Cause'''<br>
 
In some situations you are not able to register your GitLab-Runner through your proxy, but you can use the following workaround.
 
In some situations you are not able to register your GitLab-Runner through your proxy, but you can use the following workaround.
 
  
 
'''Workaround / Solution'''
 
'''Workaround / Solution'''
Zeile 60: Zeile 59:
 
*Add the copied '''token = <your_Token>''' to your GitLab-Runner '''config.toml'''.
 
*Add the copied '''token = <your_Token>''' to your GitLab-Runner '''config.toml'''.
 
*Restart your GitLab-Runner service.
 
*Restart your GitLab-Runner service.
 +
 +
 +
 +
 +
=== Encoding Issue in GitLab ===
 +
'''Issue'''<br>
 +
Some characters are broken in the GitLab CI Pipeline log/output:<br>
 +
[[Datei:01-gitlab-encoding-issue.png|1000px]]<br>
 +
 +
'''Cause'''<br>
 +
This issue exists because GitLab does not support the encoding "Windows-1251" and "Windows-1252", which is the default encoding in Windows. <br>
 +
There is still an open GitLab Issue with no solution: https://gitlab.com/gitlab-org/gitlab/-/issues/15046 <br>
 +
 +
'''Workaround'''<br>
 +
*Open the Windows Region settings in a command prompt:
 +
intl.cpl
 +
*Change the default encoding to Unicode UTF-8 (caution this is still Beta):<br>
 +
[[Datei:02-gitlab-encoding-issue.png]]
 +
  
  
  
 
[[Kategorie:PowerShell]]
 
[[Kategorie:PowerShell]]

Aktuelle Version vom 4. Mai 2020, 14:36 Uhr

Install GitLab-Runner on Windows as a Windows service

  • Create a folder somewhere in your system, ex.: C:\GitLab-Runner.
  • Download the binary and put it into the folder you created. Rename the binary to gitlab-runner.exe.
  • Run an elevated command prompt.
  • Install the Runner as a service and start it. You can either run the service using the Built-in System Account (recommended) or using a user account.
  • Run service using Built-in System Account:
.\gitlab-runner.exe install
.\gitlab-runner.exe start
  • Run service using user account:
.\gitlab-runner.exe install --user <ENTER-YOUR-USERNAME> --password <ENTER-YOUR-PASSWORD>
.\gitlab-runner.exe start
  • (Optional) Update Runners concurrent value in C:\GitLab-Runner\config.toml to allow multiple concurrent jobs as detailed in advanced configuration details. Additionally you can use the advanced configuration details to update your shell executor to use Bash or PowerShell rather than Batch.

Voila! Runner is installed, running, and will start again after each system reboot. Logs are stored in Windows Event Log More informations: https://docs.gitlab.com/runner/install/windows.html



GitLab Runner behind a proxy

  • Add your proxy server in the GitLab Runner configuration "config.toml" (for example):
 concurrent = 1
 check_interval = 0
 log_level = "warning"
 
 [session_server]
   session_timeout = 1800
 
 [[runners]]
   name = "<FQDN>"
   executor = "shell"
   shell = "powershell"
   environment = ["HTTP_PROXY=<your_Proxy>","HTTPS_PROXY=<your_Proxy>"]
   url = "https://<your_GitLab>/"
   token = "<your_token_from_registering_the_runner>"
   tls_verify = false 
  • Add the following Registry-Key to force the GitLab-Runner service to use the proxy:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\gitlab-runner\" -Name "Environment" -Value "HTTPS_PROXY=server-proxy.xaas.swissic.ch:8080" -PropertyType MultiString

Troubleshooting

Error: Registering runner... failed runner=xxxx status=couldn't execute POST against..

Error
ERROR: Registering runner... failed runner=eGycJT8v status=couldn't execute POST against https://<your_GitLab>/api/v4/runners: Post https://<your_Gitlab>.ch/api/v4/runners: dial tcp <IP>:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. PANIC: Failed to register this runner. Perhaps you are having network problems

Cause
In some situations you are not able to register your GitLab-Runner through your proxy, but you can use the following workaround.

Workaround / Solution

  • Run the register process on another machine:
.\gitlab-runner.exe register
  • Copy the token = <your_Token> from inside your new generated config.toml.
  • Add the copied token = <your_Token> to your GitLab-Runner config.toml.
  • Restart your GitLab-Runner service.



Encoding Issue in GitLab

Issue
Some characters are broken in the GitLab CI Pipeline log/output:
01-gitlab-encoding-issue.png

Cause
This issue exists because GitLab does not support the encoding "Windows-1251" and "Windows-1252", which is the default encoding in Windows.
There is still an open GitLab Issue with no solution: https://gitlab.com/gitlab-org/gitlab/-/issues/15046

Workaround

  • Open the Windows Region settings in a command prompt:
intl.cpl
  • Change the default encoding to Unicode UTF-8 (caution this is still Beta):

02-gitlab-encoding-issue.png