Contents

Install GitLab Runner on Windows

Install GitLab Runner on Windows

來源: https://docs.gitlab.com/runner/install/windows.html

Windows

  1. 建立 Runner 的 folder , ex.: C:\GitLab-Runner
  2. 下載執行檔 64-bit or 32-bit . You can download a binary for every available version as described in Bleeding Edge - download any other tagged release.
  3. 可以將下載的檔案改名成 gitlab-runner-windows-amd64.exe –> gitlab-runner.exe
  4. 安裝GitLab Runner

Install GitLab 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 (under directory created in step 1. from above, ex.: C:\GitLab-Runner)
1
2
3
cd C:\GitLab-Runner
.\gitlab-runner.exe install
.\gitlab-runner.exe start
  • Run service using user account (under directory created in step 1. from above, ex.: C:\GitLab-Runner) You have to enter a valid password for the current user account, because it’s required to start the service by Windows:
1
2
3
cd C:\GitLab-Runner
.\gitlab-runner.exe install --user ENTER-YOUR-USERNAME --password ENTER-YOUR-PASSWORD
.\gitlab-runner.exe start
  1. Registering runners /install_gitlab_runner_on_windows/images/runninger-1.png /install_gitlab_runner_on_windows/images/runninger-2.png 在你的 project -> settings -> CI/CD -> Runners 取得 urltoken

  2. 打開終端機, 將機器註冊上去

1
./gitlab-runner.exe register --url http://10.36.22.111:8180/ --registration-token $REGISTRATION_TOKEN

/install_gitlab_runner_on_windows/images/register-1.png

最後push上去就可以看到拉~ /install_gitlab_runner_on_windows/images/successed.png

Miscellaneous

fix New runner, has not contacted yet

1
.\gitlab-runner.exe verify

run local yaml

1
.\gitlab-runner.exe exec shell {{your job}}

This job is stuck because the project doesn’t have any runners online assigned to it. Go to project CI settings

/install_gitlab_runner_on_windows/images/pending.png

是因為 runner 預設 Run untagged jobs 是沒打勾 /install_gitlab_runner_on_windows/images/pending-2.png

ERROR: Job failed (system failure): prepare environment: failed to start process: exec: “pwsh”: executable file not found in %PATH%. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

/install_gitlab_runner_on_windows/images/pwsh.png

解決方法是 要將 C:\GitLab-Runnerconfig.tomlshell = "pwsh" 改成 shell = "powwershell" /install_gitlab_runner_on_windows/images/config.png

Reference