gitlab-runner:准备环境无法在 Windows 中启动进程 pwsh

har*_*ish 6 gitlab-ci gitlab-ci-runner

在新的 WIN10 机器上安装带有 shell 执行器(即 powershell)的 gitlab-runner 并启动 CI 构建会引发以下错误:

Preparing environment
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
Run Code Online (Sandbox Code Playgroud)

har*_*ish 15

发现gitlab-runner config.toml中pwshshell属性条目在某些WIN10机器上不起作用。所以我不得不编辑 confg.toml 如下:

[[runners]]
  name = "ci-runner"
  url = "http://xxx.yyy.xx/"
  token = "XXXXX"
  executor = "shell"
  shell = "pwsh"
Run Code Online (Sandbox Code Playgroud)

[[runners]]
  name = "ci-runner"
  url = "http://xxx.yyy.xx/"
  token = "XXXXX"
  executor = "shell"
  shell = "powershell"
Run Code Online (Sandbox Code Playgroud)

然后重新启动 gitlab-runner 解决了这个问题。

gitlab-runner.exe restart
Run Code Online (Sandbox Code Playgroud)

  • 这也解决了 Windows Server 2019 中的问题。 (2认同)