簡體   English   中英

修改 gitlab-runner 的 PATH

[英]Modify PATH for gitlab-runner

我想在我的 Windows 10 盒子上安裝一個gitlab-runner (執行shaell )。 我在 gitlab 服務器上開始工作,它總是以the command "git" cannot be found的消息結束(大致翻譯成英文)。 事實上git不是我的路徑的一部分。 如何修改gitlab-runner啟動的 shell 的PATH變量?

要在 windows 的命令行上使用 git 我通常使用以下語句設置它: PATH %PATH%C:\Program Files\Git\bin

它是否記錄在某處, git必須可供跑步者使用? 如何查看運行程序調用的命令行(即對 git 的調用)?

出於測試目的,我啟動了gitlab-runner如: gitlab-runner -l debug --debug run --config config.toml --service gitlab-runnergitlab-runner.execonfig.toml文件所在的目錄.

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

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

這個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%"

在 macOS 上,唯一真正對我有用的是將 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 等價物。

還可以配置gitlab-runner用戶的shell執行器環境編輯$HOME/.profile (或$HOME.bash_profile )。

要檢查gitlab-runner主目錄,請運行$ sudo cat /etc/passwd | grep gitlab-runner | cut -d: -f6 $ sudo cat /etc/passwd | grep gitlab-runner | cut -d: -f6 $ sudo cat /etc/passwd | grep gitlab-runner | cut -d: -f6

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM