From 951c5932a396db7005c7fccb0dee6f5bef022a33 Mon Sep 17 00:00:00 2001 From: Eric Sciple Date: Mon, 13 Jun 2016 14:11:55 -0400 Subject: [PATCH] Web proxy variable and default creds. --- .../WebProxy.cs | 16 +++++++++------- src/Misc/layoutroot/env.sh | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) 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=""