首页 > 解决方案 > 从 api.nuget.org 下载“BouncyCastle.1.8.6.1”时出错

问题描述

环境:Windows Server 2016 上的 Jenkins 2.249.1。

正在使用的命令是

nuget.exe install itextsharp.pdfa -PreRelease -Version 5.5.13.2 \
    -OutputDirectory C:/Jenkins/workspace/itext_7_dotnet_pdfxfa_develop/src/extras/packages \
    -Source 'C:/Jenkins/workspace/itext_7_dotnet_pdfxfa_develop/;https://api.nuget.org/v3/index.json'

这是控制台日志的相关部分:

02:17:42  Feeds used:
02:17:42    C:\Jenkins\workspace\itext_7_dotnet_pdfxfa_develop\src\extras\global-packages
02:17:42    C:/Jenkins/workspace/itext_7_dotnet_pdfxfa_develop/
02:17:42    https://api.nuget.org/v3/index.json
02:17:42  
02:17:42  
02:17:42  
02:17:42  Attempting to gather dependency information for package 'itextsharp.pdfa.5.5.13.2' with respect to project 'C:\Jenkins\workspace\itext_7_dotnet_pdfxfa_develop\src\extras\packages', targeting 'Any,Version=v0.0'
02:17:43  Gathering dependency information took 215.09 ms
02:17:43  Attempting to resolve dependencies for package 'itextsharp.pdfa.5.5.13.2' with DependencyBehavior 'Lowest'
02:17:43  Resolving dependency information took 0 ms
02:17:43  Resolving actions to install package 'itextsharp.pdfa.5.5.13.2'
02:17:43  Resolved actions to install package 'itextsharp.pdfa.5.5.13.2'
02:17:43  Retrieving package 'BouncyCastle 1.8.6.1' from 'nuget.org'.
02:17:43  Retrieving package 'iTextSharp 5.5.13.2' from 'C:/Jenkins/workspace/itext_7_dotnet_pdfxfa_develop/'.
02:17:43  Retrieving package 'itextsharp.pdfa 5.5.13.2' from 'C:/Jenkins/workspace/itext_7_dotnet_pdfxfa_develop/'.
02:17:43    GET https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg
02:17:43    OK https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg 165ms
02:17:43  WARNING: Error downloading 'BouncyCastle.1.8.6.1' from 'https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg'.
02:17:43  Could not find file 'C:\Jenkins\workspace\itext_7_dotnet_pdfxfa_develop\src\extras\global-packages\bouncycastle\1.8.6.1\bouncycastle.1.8.6.1.nupkg'.
02:17:43    GET https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg
02:17:43    OK https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg 24ms
02:17:43  WARNING: Error downloading 'BouncyCastle.1.8.6.1' from 'https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg'.
02:17:43  Could not find file 'C:\Jenkins\workspace\itext_7_dotnet_pdfxfa_develop\src\extras\global-packages\bouncycastle\1.8.6.1\bouncycastle.1.8.6.1.nupkg'.
02:17:43    GET https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg
02:17:43    OK https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg 23ms
02:17:43  WARNING: Install failed. Rolling back...
02:17:43  Executing nuget actions took 482.72 ms
02:17:43  Error downloading 'BouncyCastle.1.8.6.1' from 'https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1.nupkg'.
02:17:43    Could not find file 'C:\Jenkins\workspace\itext_7_dotnet_pdfxfa_develop\src\extras\global-packages\bouncycastle\1.8.6.1\bouncycastle.1.8.6.1.nupkg'.

看起来好像nuget install正在尝试 GET 3 次bouncycastle.1.8.6.1.nupkg看起来好像可行,而且我还验证了https://api.nuget.org/v3-flatcontainer/bouncycastle/1.8.6.1/bouncycastle.1.8.6.1。 nupkg是一个有效的 URL:当您打开此链接时,将下载一个 nupkg 文件。但是不知什么原因,无法下载?

已经试过了

packages当我从and中删除 BouncyCastle 目录global-packages,然后再次运行该作业时,BouncyCastle by 的下载nuget install成功。

当我第三次运行该作业时,没有再次清除目录,它再次因相同的错误而失败。

我需要做什么才能nuget install在所有情况下成功完成命令?

标签: jenkinsnuget

解决方案


我找不到根本原因,而且花费了太多时间,所以我采取了务实的方法。现在,我将始终在构建开始时删除 BouncyCastle,如下所示:

sh 'rm --force --recursive ${dest}/global-packages/bouncycastle'

它很脏,我并不为此感到自豪,但它确实有效。


推荐阅读