From eb78d19b17f175271cee0f4dde1fd66972558b4d Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Mon, 27 Jan 2020 11:04:35 -0500 Subject: [PATCH] Set both http_proxy and HTTP_PROXY env for runner/worker processes. (#298) --- src/Runner.Sdk/RunnerWebProxy.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Runner.Sdk/RunnerWebProxy.cs b/src/Runner.Sdk/RunnerWebProxy.cs index 18ba50120a0..7bb6f7fc4f8 100644 --- a/src/Runner.Sdk/RunnerWebProxy.cs +++ b/src/Runner.Sdk/RunnerWebProxy.cs @@ -73,6 +73,10 @@ public RunnerWebProxy() { _httpProxyAddress = proxyHttpUri.AbsoluteUri; + // Set both environment variables since there are tools support both casing (curl, wget) and tools support only one casing (docker) + Environment.SetEnvironmentVariable("HTTP_PROXY", _httpProxyAddress); + Environment.SetEnvironmentVariable("http_proxy", _httpProxyAddress); + // the proxy url looks like http://[user:pass@]127.0.0.1:8888 var userInfo = Uri.UnescapeDataString(proxyHttpUri.UserInfo).Split(':', 2, StringSplitOptions.RemoveEmptyEntries); if (userInfo.Length == 2) @@ -99,6 +103,10 @@ public RunnerWebProxy() { _httpsProxyAddress = proxyHttpsUri.AbsoluteUri; + // Set both environment variables since there are tools support both casing (curl, wget) and tools support only one casing (docker) + Environment.SetEnvironmentVariable("HTTPS_PROXY", _httpsProxyAddress); + Environment.SetEnvironmentVariable("https_proxy", _httpsProxyAddress); + // the proxy url looks like http://[user:pass@]127.0.0.1:8888 var userInfo = Uri.UnescapeDataString(proxyHttpsUri.UserInfo).Split(':', 2, StringSplitOptions.RemoveEmptyEntries); if (userInfo.Length == 2) @@ -124,6 +132,11 @@ public RunnerWebProxy() if (!string.IsNullOrEmpty(noProxyList)) { _noProxyString = noProxyList; + + // Set both environment variables since there are tools support both casing (curl, wget) and tools support only one casing (docker) + Environment.SetEnvironmentVariable("NO_PROXY", noProxyList); + Environment.SetEnvironmentVariable("no_proxy", noProxyList); + var noProxyListSplit = noProxyList.Split(',', StringSplitOptions.RemoveEmptyEntries); foreach (string noProxy in noProxyListSplit) {