diff --git a/src/Microsoft.VisualStudio.Services.Agent/WebProxy.cs b/src/Microsoft.VisualStudio.Services.Agent/WebProxy.cs index 5f59e97751..934a5e2062 100644 --- a/src/Microsoft.VisualStudio.Services.Agent/WebProxy.cs +++ b/src/Microsoft.VisualStudio.Services.Agent/WebProxy.cs @@ -37,15 +37,17 @@ public static void ApplyProxySettings() { return; } - _proxySettingsApplied = true; - var proxyFilePath = IOUtil.GetProxyConfigFilePath(); - bool proxyConfigured = (new FileInfo(proxyFilePath)).Exists; - if (!proxyConfigured) + + string proxy = Environment.GetEnvironmentVariable("VSTS_HTTP_PROXY"); + if (!string.IsNullOrEmpty(proxy)) { - return; + VssHttpMessageHandler.DefaultWebProxy = new WebProxy(new Uri(proxy)) + { + Credentials = CredentialCache.DefaultNetworkCredentials + }; } - string proxyURI = File.ReadAllText(proxyFilePath); - VssHttpMessageHandler.DefaultWebProxy = new WebProxy(new Uri(proxyURI)); + + _proxySettingsApplied = true; } } } diff --git a/src/Misc/layoutroot/env.sh b/src/Misc/layoutroot/env.sh index e8986ce440..68d765969f 100755 --- a/src/Misc/layoutroot/env.sh +++ b/src/Misc/layoutroot/env.sh @@ -9,6 +9,7 @@ varCheckList=( 'GRADLE_HOME' 'NVM_BIN' 'NVM_PATH' + 'VSTS_HTTP_PROXY' ) envContents=""