我想在我的Windows10机器上安装一个gitlab-runner (executor shaell)。我在gitlab服务器上启动了这个任务,结果总是以消息the command "git" cannot be found (大致翻译成英语)结束。事实上,git不是我的道路的一部分。如何为gitlab-runner启动的外壳修改PATH变量?
要在windows的命令行中使用git,我通常使用以下语句设置它:PATH %PATH%C:\Program Files\Git\bin。
是否有文档记录,git必须对跑步者可用?如何查看运行器调用的命令行(即对git的调用)?
发布于 2017-09-15 23:54:16
出于测试目的,我从gitlab-runner.exe和config.toml文件所在的目录启动了类似于:gitlab-runner -l debug --debug run --config config.toml --service gitlab-runner的gitlab-runner。
我将以下行添加到config.toml文件的runners部分:
environment = ['PATH=%PATH%;d:/java/bin;C:/Program Files/Git/bin;c:/program files (x86)/apache-ant-1.10.1/bin']
发布于 2019-05-08 04:53:39
此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%"发布于 2019-11-07 19:16:07
On macOS唯一对我有效的方法是this solution将路径添加到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版本。
https://stackoverflow.com/questions/46242623
复制相似问题