简体   繁体   English

在 Windows gitlab ci 中无法识别 Git

[英]Git is not recognized in Windows gitlab ci

I configured a gitlab runner as explained here: https://docs.gitlab.com/runner/install/windows.html我按照此处的说明配置了 gitlab 运行器: https ://docs.gitlab.com/runner/install/windows.html

Unfortunately, when I push to my repository, my pipeline fails:不幸的是,当我推送到我的存储库时,我的管道失败了:

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

When I open the command line utility as administrator, git is available.当我以管理员身份打开命令行实用程序时, git可用。

Any idea why git is not recognized whithin the pipeline script?知道为什么在管道脚本中无法识别git吗?

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

For me it happened that I installed git after I started PowerShell to run gitlab-runner.对我来说,我在启动 PowerShell 运行 gitlab-runner 后安装了 git。 To fix this you need to restart PowerShell after git is installed and then restart gitlab-runner to get git on your PATH.要解决此问题,您需要在安装 git 后重新启动 PowerShell,然后重新启动 gitlab-runner 以在您的 PATH 上获取 git。

My runner was installed on an Amazon EC2 instance, and I installed git after I installed the runner.我的运行器安装在 Amazon EC2 实例上,安装运行器后我安装了 git。 I found restarting the entire EC2 instance fixed it.我发现重新启动整个 EC2 实例修复了它。 Restarting the service was not enough.重新启动服务是不够的。

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

在 C:\\Git 而不是 c:\\Program Files... 上安装 Git 为我解决了这个问题。

I had installed git as a user, so it was installed to that user's AppData folder.我以用户身份安装了 git,所以它被安装到该用户的 AppData 文件夹中。 Even though I could run git --version fine from an elevated console, GitLab for some reason couldn't run it.尽管我可以从提升的控制台运行git --version ,但由于某种原因,GitLab 无法运行它。

I reinstalled git as Administrator, and then stopped and restarted the GitLab Runner service and now it is working properly.我以管理员身份重新安装了 git,然后停止并重新启动了 GitLab Runner 服务,现在它可以正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM