修改 gitlab-runner 的 PATH

Ber*_*ler 6 gitlab gitlab-ci-runner

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

To use git on the command line in windows I usually set it with the statement: PATH %PATH%C:\Program Files\Git\bin.

Is it documented somewhere, git has to be available to the runner? How can I see the command line the runner invokes (i.e. the call to git)?

Dan*_*Dan 10

这个GitLab Runner 问题回答了您的问题。

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%"
Run Code Online (Sandbox Code Playgroud)

  • 由于我的跑步者使用的是 powershell,因此我必须使用 `pre_build_script = "$Env:PATH += \";C:\\Program Files\\7-Zip\""`,但它有效。谢谢。 (2认同)

Ber*_*ler 6

出于测试目的,我开始了gitlab-runner类似的操作:gitlab-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']