Jenkins Windows从站上的dotnet恢复-值不能为空

时间:2018-06-27 00:21:06

标签: c# jenkins .net-core nuget nuget-package-restore

我有一个.Net Core应用程序,正在尝试在我们的新Jenkins服务器上构建该应用程序,并且在还原NuGet软件包时遇到了问题。

我们的新构建基础结构由在CentOS上运行的Jenkins主文件组成,并且此特定构建在Windows Server 2012从服务器上运行。两者之间的连接是通过Cygwin的SSH进行的。

此版本可以在我们的旧版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

他们使我相信,分别对于Windows和Linux,USERPROFILE或HOME变量为null是一个问题。 dotnet将这些变量用于其NuGet程序包缓存,并且在构建%USERPROFILE%.nuget \ packages的路径时,Path.Combine()方法会引发错误。

怀疑运行Linux的主服务器和运行Windows的从服务器可能存在问题,我尝试在构建节点本身上设置这两个变量(即使已经定义了USERPROFILE,我也确保明确设置了USERPROFILE) ,以及Jenkins UI中的构建节点环境变量配置。 las,我仍然遇到错误。我什至在目标输出的顶部添加了一些回显,并且您可以看到,这些变量的设置确实正确,但是dotnet restore命令仍然会引发错误。

关于我可能会缺少的任何建议吗?

1 个答案:

答案 0 :(得分:1)

我在-v diag通话中添加了dotnet。虽然输出非常冗长,但是它没有提供有关错误的更多信息(即哪个变量为null),但是我确实获得了堆栈跟踪,还有一些Googling使我想到了这一点:

.NET Core dotnet restore failing on jenkins with System.ArgumentNullException

我在Jenkins UI的从属环境变量配置中添加了LOCALAPPDATA变量,并对其进行了修复。

看来,dotnet,更具体地说是nuget cli,依靠几个Windows内置环境变量来构建路径,但是我在任何地方都找不到这些文档的列表。这是我们在Jenkins从站上定义的当前自定义变量的完整列表:

  • APPDATA
  • LOCALAPPDATA
  • TEMP
  • USERPROFILE

当然,这通常不是问题,因为它们应该始终存在于Windows系统上,但是在Jenkins从站上构建时,它会创建自己的自定义构建环境,并且您必须显式定义这些必需的内置变量你自己