1

我想要使用gitlab CI构建和测试.NET项目。从gitlab启动时GitLab Runner无法恢复nuget包,但可以在本地启动时

我已经下载并安装了最新版本的GitLab runner,并成功将其注册到我们的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本身我收到以下错误对于所有的金块包的运行构建:

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 runner和nugget.exe创建了防火墙例外(我下载并安装了最新版本的nugget.exe)

gitlab亚军服务以我用来运行手动exec命令的相同帐户登录。

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

我们背后是一个公司代理,没有设置HTTP_PROXY环境变量。该代理在“Internet选项”中进行配置。我曾尝试为nugget.exe定义HTTP_PROXY设置,但稍后在阅读nugget.exe默认使用系统代理后将其删除。

在此先感谢您的帮助!

回答

1

我碰巧看到服务列表中的服务,并注意到虽然我明确指定了服务的用户,但它是使用缺少代理设置的“本地系统”帐户创建的,我假设。该服务已得到纠正,现在可以正确构建。