GitLab CI构建失败,git无法识别

时间:2017-09-07 17:23:18

标签: git command-line gitlab gitlab-ci gitlab-ci-runner

我已经设置了一个GitLab管道,并配置了一个跑步者。构建在我提交时开始,但几乎立即失败并显示以下消息:

C:\GitLabRunner\builds\xxxxxxxx\0\cmac\portal>"git" "checkout" "-f" "-q" 
   "xxxxxxxxxxxxxxxxxxxxxxxxx" 

 '"git"' is not recognized as an internal or external command,
   operable program or batch file.

C:\GitLabRunner>IF 9009 NEQ 0 exit /b 9009 
ERROR: Job failed: exit status 9009

这是我的.gitlab-ci.yml,我已经剥离了它以试图找出问题:

stages:
 - build
variables:
  CI_DEBUG_TRACE: "true"
Build:
  stage: build
  script:
     - Echo OK

我能找到的唯一类似问题是herehere

当我在标准命令提示符中尝试使用git时因为我的PATH未在环境变量中正确设置而我在获取相同消息时,我认为我已经修复了该问题。

但是我现在已经解决了这个问题,并且我通过命令提示符从git获得预期的响应,但是当gitlab启动构建时我仍然会遇到问题。

有什么想法吗?

4 个答案:

答案 0 :(得分:1)

在buildmachine上安装新应用程序后,重新启动gitlab runner以获取路径。

答案 1 :(得分:0)

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

答案 2 :(得分:0)

我使用gitlab-ci和powershell作为执行程序。
将git路径C:\Program Files\Git\bin添加到$PATH可以解决此问题

答案 3 :(得分:0)

您是否在CI上安装了git?在我的.gitlab-ci.yml中,通过将apk update && apk add git添加到before_script来解决此问题,就像这样:

# Make sure to install all packages before running anything.
before_script:
  - apk update && apk add git
  - npm ci # For CI it's better to have this instead of npm install.