在 Windows gitlab ci 中无法识别 Git

Mar*_*lle 5 git gitlab-ci

我按照此处的说明配置了 gitlab 运行程序:https ://docs.gitlab.com/runner/install/windows.html

不幸的是,当我推送到我的存储库时,我的管道失败了:

Running with gitlab-runner 10.5.0 (80b03db9)
  on windows runner 79cb4019
Using Shell executor...
Running on WINSTD-45-13...
'"git"' is not recognized as an internal or external command,
operable program or batch file.
'"git"' is not recognized as an internal or external command,
operable program or batch file.
Cloning repository...
'"git"' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
Checking out b05fd8be as master...
'"git"' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Job failed: exit status 9009
Run Code Online (Sandbox Code Playgroud)

当我以管理员身份打开命令行实用程序时,git可用。

知道为什么git在管道脚本中无法识别吗?

小智 12

如果您在 gitlab-runner 之后安装了 git,则必须重新启动 gitlab-runner 服务。


Mar*_*lle 6

我自己解决了这个问题:我的.gitlab-ci.yml脚本正在重新定义PATH环境变量。

  • 如果可能的话,您能否添加说明您是如何做到这一点的? (2认同)
  • 我不太记得了,但如果你把你的`.gitlab-ci.yml`发布在某个地方,我也许可以告诉你。 (2认同)

小智 6

对我来说,碰巧我在启动 PowerShell 来运行 gitlab-runner 后安装了 git。要解决此问题,您需要在安装 git 后重新启动 PowerShell,然后重新启动 gitlab-runner 以将 git 添加到您的 PATH 中。