Azure Pipelines代理代理设置无法按预期工作 [英] Azure Pipelines agent proxy settings not working as expected

查看:56
本文介绍了Azure Pipelines代理代理设置无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 2016服务器上配置本地构建代理时,我使用以下代理配置设置:

When configuring a local build agent on a Windows 2016 server, I use the following proxy config settings:

.\config.cmd --proxyurl http://192.3.4.5:8080 --sslskipcertvalidation

这使生成服务器可以毫无问题地连接到代理后面的Azure DevOps,但是Powershell生成无法连接到Internet.我通过在build命令的开头设置环境变量来解决此问题:

This allows the build server to connect to Azure DevOps behind the proxy without issues, however the powershell build is having trouble connecting out to the internet. I solved this by setting an environmental variable at the beginning of the build command as such:

$env:http_proxy = "192.3.4.5:8080"

最后一个问题是构建中的一个步骤,该过程要求向直接托管在构建服务器上的VM进发,并且它无法连接.我已经尝试将代理的.proxybypass文件配置为:

The final issue is a step in the build requires to winrm to a VM hosted directly on the build server and it cannot connect. I've tried configuring the agent's .proxybypass file as such:

localhost
192\.3\.4\.*

但是,这未能解决问题.关于如何在构建步骤中设置代理绕过的任何想法?我可以设置另一个powershell env变量吗?

This has failed to solve the issue however. Any ideas on how to set the proxy bypass in the build step? Is there another powershell env variable I could set?

推荐答案

代理设置可确保座席可以调出.这些任务依赖于许多不同的技术,并且每个任务都使用不同的代理配置,IP掩码和白名单.这样,如果您的代理位于代理之后,则可能需要在所述计算机上配置许多不同的代理设置.真痛苦即使对于像我这样的任务作者,他们也不能仅仅采用代理配置并将其一对一复制到每个任务所依赖的技术上.

The proxy settings ensure the agent can call out. The tasks rely on a lot of different technologies and each use different proxy configurations, IP masks and whitelists. As such, if your agent is behind a proxy, you may need to configure a lot of different proxy settings on said machine. It's a pain. Even for task authors, like me, who can't just take the agent config and copy it one-to-one to the technology each task relies on.

Powershell依靠运行任务的用户的Windows Internet设置代理配置.您还可以覆盖.NET代理配置Powershell依赖于.NET代理设置,如何在运行中更改设置如下: https://stackoverflow.com/a/209072/736079

Powershell relies on the Windows internet settings proxy configuration for the user running the task. You can also override the .NET proxy configuration Powershell relies on the .NET proxy settings, how to change those on the fly is listed here: https://stackoverflow.com/a/209072/736079

在powershell构建中使用.NET类:

Use the .NET class in the powershell build:

[net.webrequest]::defaultwebproxy = new-object net.webproxy "http://$env:proxy_ip" 

然后添加

[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

这篇关于Azure Pipelines代理代理设置无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆