簡體   English   中英

gitlab-runner 找不到 git

[英]gitlab-runner cant find git

嘗試配置我的 gitlab CI 時出現以下錯誤,我的系統中安裝了 git,我可以從 cmd 運行 git。 這個設置是在我的本地機器上運行 gitlab runner。 這是我的 gitlab-ci.yml

stages:
  - build
  - test

before_script:
  - echo "before_script"
  - export PATH=$PATH:C:\Users\something\AppData\Local\Atlassian\SourceTree\git_local\bin

build-job:
  tags: 
    - ci
  stage: build
  script:
    - echo "Hello, $GITLAB_USER_LOGIN!"


test-job2:
  tags: 
    - ci

  stage: test
  script:
    - echo "This job tests something, but takes more time than test-job1."
    - echo "which simulates a test that runs 20 seconds longer than test-job1"
    - start matlab   -nosplash -nodesktop -minimize  -r  "run('C:\repos\ci-sandbox\unitTest\rightTriTestRunner.m');quit" -logfile C:\repos\ci-sandbox\unitTest\output.log

這是我在管道中遇到的錯誤。

Running with gitlab-runner 14.4.0 (-)
      on runner1 ------
    Resolving secrets
    00:00
    Preparing the "shell" executor
    00:00
    Using Shell executor...
    Preparing environment
    00:01
    Running on ---...
    DEPRECATION: CMD shell is deprecated and will no longer be supported
    Getting source from Git repository

    Fetching changes with git depth set to 50...
    '"git"' is not recognized as an internal or external command,
    operable program or batch file.
    Cleaning up project directory and file based variables
    
    ERROR: Job failed: exit status 9009

這類似於問題 2743

我最近在新的 Windows Server 2016 Core 安裝上遇到了類似的問題。 就我而言,我只需要確定我將 git 和 git home 定義為全局變量。

PS C:\Users\Administrator\Documents> Get-ChildItem Env:

Name                           Value
----                           -----
...
GIT                            C:\Users\Administrator\scoop\apps\git\current\cmd\git.exe
GIT_INSTALL_ROOT               C:\ProgramData\scoop\apps\git\current

我發現了問題:我的.gitlab-ci.yml腳本正在重新定義PATH環境變量,因此它覆蓋了系統中的環境變量。

在你的情況下,盡量不要重新定義PATH ,看它是否效果更好。

我有一個完全類似的問題,並嘗試了問題中的建議,但沒有任何效果。

暫無
暫無

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

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