восстановление dotnet на подчиненном устройстве Jenkins Windows - значение не может быть нулевым - PullRequest
0 голосов
/ 27 июня 2018

У меня есть приложение .Net Core, которое я пытаюсь создать на нашем новом сервере Jenkins, и у меня возникают проблемы с восстановлением пакетов NuGet.

Наша новая сборочная инфраструктура состоит из мастера Jenkins, работающего на CentOS, и эта конкретная сборка выполняется на ведомом сервере Windows Server 2012. Соединение между ними через SSH через Cygwin.

Эта сборка прекрасно работает на нашем старом Jenkins, который не имеет ведомых сборок и работает на Windows Server 2012.

Мы используем Jenkinsfile для вызова целей сборки NAnt для запуска сборки. Вот цель восстановления из файла сборки NAnt:

<target name="restore_nuget_packages" description="Restores the NuGet packages for the solution" >
    <echo message="Restoring NuGet Packages" />
    <property name="USERPROFILE" value="${environment::get-variable('USERPROFILE')}" />
    <property name="HOME" value="${environment::get-variable('HOME')}" />
    <echo message="USERPROFILE is ${USERPROFILE}" />
    <echo message="HOME is ${HOME}" />
    <exec program="${dotnet_path}" commandline="restore ${projectName}.sln"></exec>
</target>

Когда эта цель запускается на нашем новом сервере, я получаю следующий вывод:

[NuGet Restore] restore_nuget_packages:
[NuGet Restore] 
[NuGet Restore]      [echo] Restoring NuGet Packages
[NuGet Restore]      [echo] USERPROFILE is C:/Users/jenkinslvadmin
[NuGet Restore]      [echo] HOME is C:\Users\jenkinslvadmin
[NuGet Restore]      [exec]   Restoring packages for E:\Git\<some_company>.microservice.notificationdelivery\azure_build\azure_build\Microservice.NotificationDelivery\Microservice.NotificationDelivery.csproj...
[NuGet Restore]      [exec]   Restoring packages for E:\Git\<some_company>.microservice.notificationdelivery\azure_build\azure_build\Microservice.NotificationDelivery\Microservice.NotificationDelivery.csproj...
[NuGet Restore]      [exec]   Restoring packages for E:\Git\<some_company>.microservice.notificationdelivery\azure_build\azure_build\Microservice.NotificationDelivery.Tests\Microservice.NotificationDelivery.Tests.csproj...
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.VisualStudio.Web.CodeGeneration.Tools'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.VisualStudio.Web.CodeGeneration.Tools'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.NETCore.App'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.NETCore.App'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='jose-jwt'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='jose-jwt'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='AutoMapper'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='AutoMapper'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='MailKit'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='MailKit'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='AutoMapper.Extensions.Microsoft.DependencyInjection'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='AutoMapper.Extensions.Microsoft.DependencyInjection'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='FluentValidation.AspNetCore'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec] c:\program files\dotnet\sdk\2.1.301\NuGet.targets(114,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [E:\Git\<some_company>.microservice.notificationdelivery\azure_build\azure_build\Microservice.NotificationDelivery.sln]
[NuGet Restore]      [exec] c:\program files\dotnet\sdk\2.1.301\NuGet.targets(114,5): error :   Value cannot be null. [E:\Git\<some_company>.microservice.notificationdelivery\azure_build\azure_build\Microservice.NotificationDelivery.sln]
[NuGet Restore]      [exec] c:\program files\dotnet\sdk\2.1.301\NuGet.targets(114,5): error :   Parameter name: path1 [E:\Git\<some_company>.microservice.notificationdelivery\azure_build\azure_build\Microservice.NotificationDelivery.sln]
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='FluentValidation.AspNetCore'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.CodeAnalysis.CSharp.Workspaces'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.CodeAnalysis.CSharp.Workspaces'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.EntityFrameworkCore'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.EntityFrameworkCore'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.EntityFrameworkCore.SqlServer'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.EntityFrameworkCore.SqlServer'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.NET.Test.Sdk'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Microsoft.NET.Test.Sdk'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Moq'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='Moq'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='NUnit'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='NUnit'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='NUnit3TestAdapter'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='NUnit3TestAdapter'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='<some_company>.Microservice.Core.Contracts'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='<some_company>.Microservice.Core.Contracts'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='<some_company>.Microservice.Core.ServiceBus'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='<some_company>.Microservice.Core.ServiceBus'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='<some_company>.Microservice.Core.State'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore]      [exec]   Retrying 'FindPackagesByIdAsyncCore' for source 'https://proget.<some_company>.com/nuget/Microservice.Core/FindPackagesById()?id='<some_company>.Microservice.Core.State'&semVerLevel=2.0.0'.
[NuGet Restore]      [exec]   Value cannot be null.
[NuGet Restore]      [exec]   Parameter name: path1
[NuGet Restore] 
[NuGet Restore] BUILD FAILED

Я обнаружил и другие подобные проблемы:

https://github.com/dotnet/core/issues/1037#issuecomment-338315953 https://blog.jongallant.com/2017/12/dotnet-value-cannot-be-null-parameter-name-path1/ https://github.com/dotnet/cli/issues/2385

Они наводят меня на мысль, что проблема в том, что переменные USERPROFILE или HOME имеют значение null для Windows и Linux соответственно. dotnet использует эти переменные для своего кэша пакетов NuGet, и метод Path.Combine () выдает ошибку при построении пути к% USERPROFILE% .nuget \ packages.

Подозревая, что это может быть проблема с мастером под управлением Linux и ведомым устройством под управлением Windows, я попытался установить обе эти переменные на самом узле сборки (я убедился, что установил USERPROFILE явно, даже если он уже должен быть определен) , а также в конфигурации переменных среды узла сборки в пользовательском интерфейсе Jenkins. Увы, я все еще получаю ошибку. Я даже включил эхо в верхнюю часть целевого вывода, и, как вы можете видеть, эти переменные действительно установлены правильно, но команда dotnet restore все еще выдает ошибку.

Любые предложения о том, что я мог бы пропустить?

1 Ответ

0 голосов
/ 27 июня 2018

Я добавил -v diag к вызову dotnet. Хотя вывод был ОЧЕНЬ подробным, он не давал намного больше информации об ошибке (то есть, какая переменная была нулевой), но я получил трассировку стека, и некоторое дополнительное прибегание к поиску привело меня к этому:

.NET Core dotnet не удается восстановить на jenkins с System.ArgumentNullException

Я добавил переменную LOCALAPPDATA в конфигурацию переменной ведомого env в пользовательском интерфейсе Jenkins, и это исправило ее.

Похоже, что dotnet, а точнее nuget cli, использует несколько встроенных переменных среды Windows для построения путей, но я нигде не могу найти их список. Вот текущий полный список пользовательских переменных, которые мы определили на нашем подчиненном устройстве Jenkins:

  • APPDATA
  • LOCALAPPDATA
  • TEMP
  • USERPROFILE

Конечно, это, как правило, не проблема, поскольку они всегда должны существовать в системе Windows, но при сборке на подчиненном устройстве Jenkins создается собственная пользовательская среда сборки, и вы должны явно определить эти обязательные встроенные переменные. сам.

...