2
votes

Triggering a build from Visual Studio Team Services on an on-premise vNext build agent fails at the point of getting sources from the repo, presumably because of a corporate proxy. The build log on VSTS shows:

2016-01-28T12:35:03.7688078Z Syncing repository: MyProject (TFVC)
2016-01-28T12:35:03.7688078Z workspaceName=ws_3_3
2016-01-28T12:35:05.0730362Z ##[error]HTTP code 407: Proxy Authentication Required
2016-01-28T12:35:05.3257849Z ##[error]Prepare repository failed with exception.

On the build server the agent log shows the following exception:

16:17:14.895983 System.AggregateException: One or more errors occurred. ---> Microsoft.TeamFoundation.DistributedTask.Agent.Common.AgentExecutionTerminationException: Prepare repository failed with exception. ---> Microsoft.TeamFoundation.TeamFoundationServiceUnavailableException: HTTP code 407: Proxy Authentication Required ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.

16:17:14.895983    at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)    
16:17:14.895983    at System.Net.HttpWebRequest.GetRequestStream()
16:17:14.895983    at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequestAndGetResponse(HttpWebRequest webRequest, WebException& webException)
16:17:14.895983    --- End of inner exception stack trace ---
16:17:14.895983    at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.ReadResponse(HttpWebResponse webResponse, WebException webException)
16:17:14.895983    at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.IsAuthenticationChallenge(TfsMessage requestMessage, HttpWebResponse webResponse, WebException webException, TfsMessage& responseMessage)
16:17:14.895983    at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest()
16:17:14.895983    at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout)
16:17:14.895983    at Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs)
16:17:14.895983    at Microsoft.TeamFoundation.Framework.Client.LocationWebService.Connect(Int32 connectOptions, Int32 lastChangeId, Int32 features)
16:17:14.895983    at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.Connect(ConnectOptions connectOptions)
16:17:14.895983    at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.EnsureConnected(ConnectOptions optionsNeeded)
16:17:14.895983    at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.get_AuthorizedIdentity()
16:17:14.895983    at Microsoft.TeamFoundation.VersionControl.Client.Client.ResolveUserUniqueName(String user)
16:17:14.895983    at Microsoft.TeamFoundation.VersionControl.Client.Client.GetLocalWorkspace(String workspaceName, String workspaceOwner)
16:17:14.895983    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.TfvcHelper.SyncRepository(VersionControlServer server, Uri repositoryUrl, String workspaceName, String rootPath, WorkingFolder[] workingFolders, String sourceVersion, Boolean cleanRepository, String shelveset, CancellationToken cancellationToken)
16:17:14.895983    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.TfvcHelper.Sync(ITaskEndpoint endpoint, String localPath, Dictionary`2 serverPathMapping, String sourceVersion, Boolean cleanRepository, String workspaceName, String shelveset, String& actualSourceVersion, CancellationToken cancellationToken)
16:17:14.895983    at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.TfvcSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
16:17:14.895983    --- End of inner exception stack trace ---

There are a lot of similar questions about the 407 proxy authentication error, with suggestions of config files to change, but none specific to the problem of the vNext build agent. Is there a config file somewhere that I can edit to fix this problem?

2

2 Answers

2
votes

The config file you need to change is VsoWorker.exe.config, which can be found in the following kind of location C:\BuildAgent\TFS_Build\agent\agent\Worker.

Within the <configuration> block add the following code:

<system.net>
  <defaultProxy useDefaultCredentials="true">
  </defaultProxy>
</system.net>
0
votes

I'm using VSTS behind a corporate proxy but have already set my git proxy up globally. If I've done this (so can pull from the collection from the command line) then using the latest vso agent it just works:

https://github.com/Microsoft/vsts-agent