GitLab Runner 在从 gitlab 启动时无法恢复 nuget 包,但在本地启动时可以

GitLab Runner unable to restore nuget packages when started from gitlab but can when started locally

我正在尝试使用 gitlab CI.

构建和测试 .NET 项目

我已经下载并安装了最新版本的 GitLab 运行ner 并成功将其注册到我们的 gitlab 实例。我创建了以下 .gitlab-ci.yaml 文件:

variables:
  Solution: Performance-Validation-Tool.sln

stages:
  - build
  - test
#  - deploy

build:
  stage: build
  script:
  - echo "Restoring NuGet packages..."
  - 'C:/nuget/NuGet.exe restore'
  - echo building...
  - 'msbuild.exe "%Solution%"'
  except:
  - tags

test:
  stage: test
  script:
  - echo testing...
  - 'msbuild.exe "%Solution%"'
  - dir /s /b *.Tests.dll | findstr /r Tests\*\bin\ > testcontainers.txt
  - 'for /f %%f in (testcontainers.txt) do mstest.exe /testcontainer:"%%f"'
  except:
  - tags

重要的部分是构建操作。

如果我 运行 从 Gitlab 本身构建,我会收到以下所有 nugget 包的错误:

WARNING: Unable to find version '3.5.0' of package 'NUnit.Console'.

  C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache: Package 'NUnit.Console.3.5.0' is not found on source 'C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache'.

  https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.

  An error occurred while sending the request.

  The remote name could not be resolved: 'api.nuget.org'

但是,如果我 运行 本地命令如下:

C:\GitlabRunner\gitlab-ci-multi-runner-windows-amd64.exe exec shell build

一切正常...

我已经为 gitlab 运行ner 和 nugget.exe 创建了防火墙例外(我下载并安装了最新版本的 nugget.exe)

gitlab 运行ner 服务以我用于运行 手动执行命令的同一帐户登录。

我对 gitlab 触发构建和手动 exec 命令使用了相同的 nugget.exe。

我们在公司代理后面,没有设置 HTTP_PROXY 环境变量。代理在 "internet options" 中配置。我确实尝试为 nugget.exe 定义 HTTP_PROXY 设置,但后来在阅读 nugget.exe 默认使用系统代理后将其删除。

在此先感谢您的帮助!

我偶然查看了服务列表中的服务,注意到虽然我已明确指定该服务的用户,但它是使用缺少代理设置的 "local system" 帐户创建的,我想.服务已更正,现在可以正确构建。