修改gitlab-runner的PATH

时间:2017-09-15 15:04:48

标签: gitlab gitlab-ci-runner

我想在我的Windows 10机器上安装gitlab-runner(执行者shaell)。我在gitlab服务器上开始工作,它总是以the command "git" cannot be found消息结束(大致翻译成英文)。 事实上git不是我道路的一部分。 如何修改PATH启动的shell的gitlab-runner变量?

要在Windows命令行中使用git,我通常使用语句PATH %PATH%C:\Program Files\Git\bin设置它。

是否在某处记录,git必须为跑步者提供? 如何查看转轮调用的命令行(即调用git)?

3 个答案:

答案 0 :(得分:4)

出于测试目的,我从gitlab-runnergitlab-runner -l debug --debug run --config config.toml --service gitlab-runner文件所在的目录中启动了gitlab-runner.exe,如:config.toml

我将以下行添加到runners文件的config.toml部分:

environment = ['PATH=%PATH%;d:/java/bin;C:/Program Files/Git/bin;c:/program files (x86)/apache-ant-1.10.1/bin']

答案 1 :(得分:0)

GitLab Runner issue回答了您的问题。

environment设置不起作用,因为它会在设置变量之前进行评估,但是您可以在运行程序配置中使用pre_build_script来更新路径。

[[runners]]
  name = "My Runner"
  url = "https://gitlab.com/"
  token = "Abcd1234"
  executor = "shell"
  pre_build_script = "set Path=%GIT_HOME%\\usr\\bin;%Path%"

答案 2 :(得分:0)

在macOS上,对我真正有用的唯一操作是this solution,将PATH添加到Library/LaunchAgents/gitlab-runner.plist

<key>EnvironmentVariables</key>
<dict>
    <key>PATH</key>
    <string>/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>

然后重新启动gitlab-runner,您一切顺利。

我想也有Windows等效的解决方案。