2

尝试配置我的 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
4

2 回答 2

0

这类似于问题 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, 以查看它是否效果更好。

于 2021-10-30T00:29:25.040 回答
0

我有一个完全相同的问题,并尝试了问题中的建议,但还没有任何效果。

于 2021-11-01T03:46:17.593 回答