Skip to content

Commit

Permalink
Set both http_proxy and HTTP_PROXY env for runner/worker processes. (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang authored Jan 27, 2020
1 parent 17970ad commit eb78d19
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Runner.Sdk/RunnerWebProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
{
Expand Down

0 comments on commit eb78d19

Please sign in to comment.