首页 > 解决方案 > 下载工件失败忽略 http_proxy

问题描述

我们看到 Azure Release Pipelines 无法在某个服务器上下载工件 - 大约 2 分钟后超时,我们怀疑这是代理问题,即代理没有使用它配置为使用的代理。

当我们禁用/绕过工件下载并让代理运行 curl 命令时,我们看到它在访问 HTTPS URL 时也会超时,但 HTTP URL 很好。curl https://curl.haxx.se所以我们可以用例如重现这个问题。直接在服务器上运行此命令(作为 root 或任何用户)工作正常,因此这是一个代理问题。

当我们告诉代理export https_proxy=<our proxy>(注意 http S)然后是 CURL 时,对 HTTPS 的调用成功。这意味着 CURL 知道我们的HTTP_PROXY但不知道HTTPS_PROXY,并且 curl 似乎忽略HTTP_PROXY了 HTTPS 域。我们怀疑代理通过/设置 HTTP_PROXY 但不是 HTTP_PROXY!

问题是我们无法export在工件下载之前运行命令,因为这始终是部署组中的第一步,然后才能执行任何脚本。

除了我们在export http_proxy其中export https_proxy正确定义的事实之外/etc/environment,天蓝色管道在尝试下载工件时似乎不知道代理。我们的.proxy文件包含代理http://proxy.ourlandomain:3333,它在代理日志中显示为:

Agent is running behind proxy server: 'http://proxy.ourlandomain.com:3333'

……然后后来……

[AGENT_PROXYURL] --> [http://proxy.ourlandomain.com:***@ourdomain.com]

它看起来有点乱码。3333它是作为一个秘密隐藏起来的吗?这***@ourdomain.com从哪里来的???

最后,代理以 root 身份运行,当我们以 root 身份 curl HTTPS URL 时,它工作正常。

为什么代理不使用代理或为什么工件下载失败?

2020-07-06T13:15:26.6383041Z ##[debug]Evaluating condition for step: 'Download artifact - Test1Artifact - Test1Linux'
2020-07-06T13:15:26.6423849Z ##[debug]Evaluating: succeeded()
2020-07-06T13:15:26.6429537Z ##[debug]Evaluating succeeded:
2020-07-06T13:15:26.6469145Z ##[debug]=> True
2020-07-06T13:15:26.6477846Z ##[debug]Result: True
2020-07-06T13:15:26.6517309Z ##[section]Starting: Download artifact - Test1Artifact - Test1Linux
2020-07-06T13:15:26.6717563Z ==============================================================================
2020-07-06T13:15:26.6718055Z Task         : Download pipeline artifact
2020-07-06T13:15:26.6718463Z Description  : Download a named artifact from a pipeline to a local path
2020-07-06T13:15:26.6718700Z Version      : 1.2.5
2020-07-06T13:15:26.6719046Z Author       : Microsoft Corporation
2020-07-06T13:15:26.6719901Z Help         : Download a named artifact from a pipeline to a local path
2020-07-06T13:15:26.6720216Z ==============================================================================
2020-07-06T13:15:26.9979976Z Download from the specified build: #81654
2020-07-06T13:15:26.9980651Z Download artifact to: /prg/azure/deploy2/_work/r1/a/Test1Artifact/Test1Linux
2020-07-06T13:15:30.3332655Z ##[debug]Dedup parallelism: 192
2020-07-06T13:17:10.3457179Z ##[error]One or more errors occurred. (A task was canceled.)
2020-07-06T13:17:10.3471565Z ##[debug]Processed: ##vso[task.logissue type=error;]One or more errors occurred. (A task was canceled.)
2020-07-06T13:17:10.3485598Z ##[debug]Processed: ##vso[task.complete result=Failed;]
2020-07-06T13:17:10.3510288Z ##[debug]   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.VisualStudio.Services.BlobStore.Common.Telemetry.BlobStoreApplicationInsightsTelemetrySender..ctor(IAppTraceSource tracer, Uri baseAddress)
   at Microsoft.VisualStudio.Services.BlobStore.Common.Telemetry.BlobStoreClientTelemetry..ctor(IAppTraceSource tracer, Uri baseAddress)
   at Agent.Plugins.PipelineArtifact.DedupManifestArtifactClientFactory.CreateDedupManifestClient(AgentTaskPluginExecutionContext context, VssConnection connection, CancellationToken cancellationToken, BlobStoreClientTelemetry& telemetry)
   at Agent.Plugins.PipelineArtifact.PipelineArtifactServer.DownloadAsync(AgentTaskPluginExecutionContext context, PipelineArtifactDownloadParameters downloadParameters, DownloadOptions downloadOptions, CancellationToken cancellationToken)
   at Agent.Plugins.PipelineArtifact.DownloadPipelineArtifactTaskV1.ProcessCommandInternalAsync(AgentTaskPluginExecutionContext context, CancellationToken token)
   at Agent.PluginHost.Program.Main(String[] args)
2020-07-06T13:17:10.3588657Z ##[section]Finishing: Download artifact - Test1Artifact - Test1Linux

更新:Environment=https_proxy=http://proxy.ourlandomain.com:3333在代理的 systemd 配置中设置解决了问题并下载了工件。似乎下载工件任务不尊重http_proxy或代理应该并且没有设置https_proxy

标签: proxyazure-devopsazure-pipelines

解决方案


下载工件失败忽略 http_proxy

根据文档Run a self-hosted agent behind a web proxy

当您的自托管代理需要 Web 代理时,您可以在配置期间通知代理有关代理的信息。这允许您的代理通过代理连接到 Azure Pipelines 或 TFS。这反过来又允许代理获取资源并下载工件

因此,您可以参考上述文档并配置代理权限以再次检查。

此外,作为解决方法,我们可以禁用默认的内置工件下载任务:

在此处输入图像描述

然后,我们可以运行export命令并使用任务下载构建工件来下载工件。

希望这可以帮助。


推荐阅读