Build agent is unable to download available workspaces - tfs

We recently upgraded TFS from TFS 2015 to TFS 2018. We changed build agent in our infrastructure to new agent version 2.122.1
When developers commit their changesets or planed build is executed, sometimes build is processed as expected, but sometimes we receive an strange error upon retrieving sources from TFS repository.
In build log they are logged as:
2018-01-03T15:01:25.6074314Z Querying workspace information.
2018-01-03T15:01:26.5136788Z ##[error]There is an error in XML document (1, 1).
If I open agent detailed log, I got an following information:
[2018-01-03 15:01:25Z INFO ProcessInvoker] Starting process:
[2018-01-03 15:01:25Z INFO ProcessInvoker] File name: 'tf'
[2018-01-03 15:01:25Z INFO ProcessInvoker] Arguments: 'vc workspaces
/format:xml /collection:http://servername:8080/tfs/ProjectCollection/
/loginType:OAuth /login:.,******** /noprompt'
[2018-01-03 15:01:25Z INFO ProcessInvoker] Working directory:
'C:\Agent2017\_work\10\s'
[2018-01-03 15:01:25Z INFO ProcessInvoker] Require exit code zero:
'True'
[2018-01-03 15:01:25Z INFO ProcessInvoker] Encoding web name:
windows-1252 ; code page: '1252'
[2018-01-03 15:01:25Z INFO ProcessInvoker] Force kill process on
cancellation: 'False'
[2018-01-03 15:01:25Z INFO ProcessInvoker] Process started with
process id 3524, waiting for process exit.
[2018-01-03 15:01:25Z INFO JobServerQueue] Try to append 1 batches web
console lines, success rate: 1/1.
[2018-01-03 15:01:25Z INFO JobServerQueue] Try to upload 1 log files
or attachments, success rate: 1/1.
[2018-01-03 15:01:26Z INFO ProcessInvoker] Finished process with exit
code 0, and elapsed time 00:00:00.5240505.
[2018-01-03 15:01:26Z ERR StepsRunner] Caught exception from step:
System.InvalidOperationException: There is an error in XML document
(1, 1). ---> System.Xml.XmlException: Data at the root level is
invalid. Line 1, position 1. at
System.Xml.XmlTextReaderImpl.Throw(Exception e) at
System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at
System.Xml.XmlTextReaderImpl.ParseDocumentContent() at
System.Xml.XmlTextReaderImpl.Read() at
System.Xml.XmlReader.MoveToContent() at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderTFWorkspaces.Read5_Workspaces()
--- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, Object events) at
System.Xml.Serialization.XmlSerializer.Deserialize(TextReader
textReader) at
Microsoft.VisualStudio.Services.Agent.Worker.Build.TFCommandManager.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Services.Agent.Worker.Build.TfsVCSourceProvider.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Services.Agent.Worker.Build.BuildJobExtension.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Services.Agent.Worker.JobExtensionRunner.d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.d__1.MoveNext()
[2018-01-03 15:01:26Z INFO StepsRunner] Step result: Failed
It seems that agent is trying to get list of available workspaces, but it fails. If I try to execute command under appropriate permissions at computer, where agent is running, I get proper list of workspaces.

Try to queue build with system.debug = true, and you'll get more information in the log. Check the log to get detailed error message.
Remove all the workspaces created by the build process like the following name: ws_1_2 in VS/Team Explorer, and set the clean option in the Get Source task to true, then try to run the build again.

Finally I found an answer to my problem here.
Problem was caused by cached agent information and when I manually executed vc workspaces /format:xml /collection:http://servername:8080/tfs/ProjectCollection/ command at build machine, sometimes I got workspace list, but sometimes I got warning plus workspace list (result is not expected to be same after each call dependent on cache usage). Due to warning like
Local path C:\Agent2017_work\10\s is mapped both in workspace ws_11_09;ProjectCollection Build Service on server http://rwstfs:8080/tfs/ProjectCollection/ and workspace ws_09_10;ProjectCollection Build Service on server http://rwstfs:8080/tfs/ProjectCollection/. Removing workspace ws_09_10;ProjectCollection Build Service on server http://rwstfs:8080/tfs/ProjectCollection/ from the cache. Please remove conflicting mappings.
agent is not able to parse xml document, because it is preceded by non-sgml part.
So I went to
%LocalAppData%\Microsoft\Team Foundation\7.0\Cache
directory, deleted cache content and problem was gone.
EDIT:
Alternative way could be delete cached workspaces using command
tf workspaces /remove:*

Related

Docker Desktop Installation failed 4.7.0 (Manifest extraction failed: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe)

Docker Desktop 4.7.0 installation fails instantly, log file below.
If I try to download an older version <4.5, then the download will start but after bootup the same error comes to light. My guess is that something is wrong with the System.Runtime.CompilerServices.Unsafe assembly file.
Any ideas what might actually be causing this and what are possible fixes?
Log file:
"Version: 4.7.0 (77141)
Sha1:
Started on: 2022/04/10 15:38:12.555
Resources: C:\Users\Me\Downloads\resources
OS: Windows 10 Home
Edition: Core
Id: 2009
Build: 19044
BuildLabName: 19041.1.amd64fre.vb_release.191206-1406
File: C:\ProgramData\DockerDesktop\install-log-admin.txt
CommandLine: "C:\Users\Kaur\Downloads\Docker Desktop Installer4.7ERROR.exe"
You can send feedback, including this log file, at https://github.com/docker/for-win/issues
[2022-04-10T15:38:12.821384600Z][ManifestAndExistingInstallationLoader][Info ] No install path specified, looking for default installation registry key
[2022-04-10T15:38:12.837008100Z][Installer ][Info ] No installation found
[2022-04-10T15:38:13.061938200Z][InstallWorkflow ][Info ] Cancel pending background download
[2022-04-10T15:38:13.061938200Z][BackgroundTransfer][Info ] Cancel current background transfer job
[2022-04-10T15:38:17.390107900Z][InstallWorkflow ][Info ] Using package: res:DockerDesktop
[2022-04-10T15:38:17.390107900Z][InstallWorkflow ][Info ] Downloading
[2022-04-10T15:38:18.922416300Z][InstallWorkflow ][Info ] Extracting manifest
[2022-04-10T15:38:19.029412900Z][InstallWorkflow ][Error ] Installation failed System.Exception: Manifest extraction failed: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest. ---> System.BadImageFormatException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.
at System.Span`1.Create(T[] array, Int32 start)
at SharpCompress.Compressors.LZMA.LzmaStream..ctor(Byte[] properties, Stream inputStream, Int64 inputSize, Int64 outputSize, Stream presetDictionary, Boolean isLzma2)
at SharpCompress.Compressors.LZMA.LzmaStream..ctor(Byte[] properties, Stream inputStream, Int64 inputSize, Int64 outputSize)
at SharpCompress.Compressors.LZMA.DecoderRegistry.CreateDecoderStream(CMethodId id, Stream[] inStreams, Byte[] info, IPasswordProvider pass, Int64 limit)
at SharpCompress.Compressors.LZMA.DecoderStreamHelper.CreateDecoderStream(Stream inStream, Int64 startPos, Int64[] packSizes, CFolder folderInfo, IPasswordProvider pass)
at SharpCompress.Common.SevenZip.ArchiveReader.ReadAndDecodePackedStreams(Int64 baseOffset, IPasswordProvider pass)
at SharpCompress.Common.SevenZip.ArchiveReader.ReadDatabase(IPasswordProvider pass)
at SharpCompress.Archives.SevenZip.SevenZipArchive.LoadFactory(Stream stream)
at SharpCompress.Archives.SevenZip.SevenZipArchive.<LoadEntries>d__11.MoveNext()
at SharpCompress.LazyReadOnlyCollection`1.LazyLoader.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at CommunityInstaller.ExtractManifestStep.<DoAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CommunityInstaller.InstallWorkflow.<DoHandleD4WPackageAsync>d__29.MoveNext()
--- End of inner exception stack trace ---
at CommunityInstaller.InstallWorkflow.<DoHandleD4WPackageAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CommunityInstaller.InstallWorkflow.<DoProcessAsync>d__23.MoveNext()
[2022-04-10T15:38:19.032411200Z][InstallWorkflow ][Info ] Rollbacking component CommunityInstaller.DownloadStep
[2022-04-10T15:38:19.889337800Z][Installer ][Warning] Failed to track the installer started event
"

Docker Windows Installation Failed / Library not registered [Windows 10 Pro]

I am trying to install Docker for Windows 10 Pro. I have downloaded the Docker Desktop Installer.exe and when I run it with Administrator role I got the follwing error when it starts the installation, just after downloading and unpackaging the files.
Installation failed
Library not registered.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.RefreshCache()
at System.DirectoryServices.AccountManagement.PrincipalContext.DoMachineInit()
at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)
at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, String identityValue)
at System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext context, String identityValue)
at CommunityInstaller.CreateGroupAction.<DoAsync>b__33_0()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at CommunityInstaller.InstallWorkflow.<HandleD4WPackageAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CommunityInstaller.InstallWorkflow.<ProcessAsync>d__24.MoveNext(
I have changed my Windows user Group to Administrators and I also updated Windows 10.
Any help would be appreciated
Regards

Visual Studio Test Run: Run Coded UI automated tests from test plans in the Test hub

Build Definition
I am using the same machine as Build and Release configuration. I have created build successfully. Using build I am able to execute Coded UI scripts in Visual Studio Test Task in build and they are working fine My configuration is for build definition is mentioned below
Release Destination
after successful build definition and execution of test scripts, My next plan is to Run Automated Tests from Test plans in the Test Hub. I have associated my test scripts with Test cases also. Please have a look at the image of my release definition where I have selected Test Run using the Test run
Notification I receive after failed execution of automated test from test plan in test hub is
Deployment of release Release-11 Rejected in Deploy Test Scripts.
Log
2018-02-21T14:24:20.8978238Z AgentName: EVSRV017-DEVSRV017-4
2018-02-21T14:24:20.8978238Z AgentId: 29
2018-02-21T14:24:20.9038250Z ServiceUrl: https://mytfsserver/tfs/DefaultCollection/
2018-02-21T14:24:20.9038250Z TestPlatformVersion:
2018-02-21T14:24:20.9038250Z EnvironmentUri: dta://env/Calculator/_apis/release/16/20/1
2018-02-21T14:24:20.9038250Z QueryForTaskIntervalInMilliseconds: 3000
2018-02-21T14:24:20.9038250Z MaxQueryForTaskIntervalInMilliseconds: 10000
2018-02-21T14:24:20.9048252Z QueueNotFoundDelayTimeInMilliseconds: 3000
2018-02-21T14:24:20.9058254Z MaxQueueNotFoundDelayTimeInMilliseconds: 50000
2018-02-21T14:24:20.9058254Z RetryCountWhileConnectingToTfs: 3
2018-02-21T14:24:20.9058254Z ===========================================
2018-02-21T14:24:21.3909224Z Initializing the Test Execution Engine
Warning
2018-02-21T14:25:02.1240674Z ##[warning]Failure attempting to call the restapis. Exception: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
2018-02-21T14:25:02.1240674Z at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
2018-02-21T14:25:02.1240674Z at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
2018-02-21T14:25:02.1240674Z --- End of inner exception stack trace ---
ERROR:
2018-02-22T10:10:42.0007605Z ##[error]System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
I added debug variable and it seems that when creating a setting file, it is something like system.io exception.
Enabled DEBUG LOG
2018-02-22T20:17:53.8151287Z Initializing the Test Execution Engine
2018-02-22T20:17:53.8161287Z ##[debug]Creating test settings. test settings name : 44de4d5b-f134-4ba2-b0de-ebd8d30b4d22
2018-02-22T20:18:35.3911287Z ##[warning]Failure attempting to call the restapis. Exception: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
2018-02-22T20:18:35.3931287Z ##[debug]Processed: ##vso[task.logissue type=warning;]Failure attempting to call the restapis. Exception: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
TFS Agent Log
[INFO VstsAgentWebProxy] No proxy setting found.
[INFO ConfigurationStore] IsServiceConfigured: False
[INFO ConfigurationManager] Is service configured: False
Worker Log
[2018-02-23 19:32:17Z INFO VstsAgentWebProxy] No proxy setting found.
[2018-02-23 19:32:52Z INFO JobServerQueue] Try to append 1 batches web console lines, success rate: 1/1.
[2018-02-23 19:32:52Z INFO JobServerQueue] Try to append 1 batches web console lines, success rate: 1/1.
[2018-02-23 19:32:53Z INFO JobServerQueue] Try to append 1 batches web console lines, success rate: 1/1.
[2018-02-23 19:33:34Z INFO JobServerQueue] Catch exception during update timeline records, try to update these timeline records next time.
[2018-02-23 19:33:34Z INFO ProcessInvoker] Finished process with exit code 0, and elapsed time 00:00:49.0055812.
[2018-02-23 19:33:34Z INFO StepsRunner] Step result: Failed
[2018-02-23 19:33:34Z INFO StepsRunner] Update job result with current step result 'Failed'.
[2018-02-23 19:33:34Z INFO StepsRunner] Current state: job state = 'Failed'
[2018-02-23 19:33:34Z INFO JobRunner] Job result after all job steps finish: Failed
[2018-02-23 19:33:34Z INFO JobRunner] Run all post-job steps.
[2018-02-23 19:33:34Z INFO JobRunner] Job result after all post-job steps finish: Failed
[2018-02-23 19:33:34Z INFO JobRunner] Completing the job execution context.
[2018-02-23 19:33:34Z INFO JobServerQueue] Try to append 2 batches web console lines, success rate: 2/2.
[2018-02-23 19:33:34Z INFO JobRunner] Shutting down the job server queue.
[2018-02-23 19:33:34Z ERR JobServerQueue] Microsoft.VisualStudio.Services.Common.VssServiceException: String or binary data would be truncated.
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponse(HttpResponseMessage response)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__48.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__45`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__27`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__26`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.JobServerQueue.<ProcessTimelinesUpdateQueueAsync>d__32.MoveNext()
[2018-02-23 19:33:34Z INFO JobServerQueue] Fire signal to shutdown all queues.
[2018-02-23 19:33:35Z INFO JobServerQueue] All queue process task stopped.
[2018-02-23 19:33:35Z INFO JobServerQueue] Try to append 1 batches web console lines, success rate: 1/1.
[2018-02-23 19:33:35Z INFO JobServerQueue] Web console line queue drained.
[2018-02-23 19:33:35Z INFO JobServerQueue] Try to upload 2 log files or attachments, success rate: 2/2.
[2018-02-23 19:33:35Z INFO JobServerQueue] File upload queue drained.
[2018-02-23 19:33:35Z INFO JobServerQueue] Timeline update queue drained.
[2018-02-23 19:33:35Z INFO JobServerQueue] All queue process tasks have been stopped, and all queues are drained.
[2018-02-23 19:33:35Z INFO JobRunner] Raising job completed event.
[2018-02-23 19:33:35Z INFO Worker] Job completed.
I will be thankful to you if anyone can identify where I am missing something or what I need to fix this issue so that I can execute automated tests from test plans in the test hub.
Regards
Based on the error message "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." and your clarification. It should be related to the known issue on win server 2008 R2. Please refer to below article for details:
Team Foundation Server: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
However the bug has been fixed by the Windows team and they have
released a QFE for it. You can find the QFE here. You will
need to install it on all of your ATs.
So, just try to install the hotfix and restart the computer after you apply this hotfix, then try it again.
You can also try to use the initial workarounds that list in the blog:
Open the IIS Manager
In the Connections pane, make sure the name of your AT is selected.
In the middle pane (titled “ Home”), make sure you are
in the “Features View” (bottom) and scroll down to the Management
section.
Double-click the “Configuration Editor” icon.
The middle pane should now have the title “Configuration Editor”.
In the Section pull down near the top, expand the
system.applicationHost and select “webLimits”.
You should now see a bunch of property value pairs, one of which is
named “minBytesPerSecond”. Its value is most like 240. You will
want to lower this value for the workaround.
Besides, another possibility is that it's caused by the Proxy server, just try to bypass the proxy server, then check it again.

How to clean sources on multiple build agents

Let's say you have multiple build agents configured and you have a folder on the build agents that has some content in it that isn't from TFS (even specifying Output, some intermediate stuff like the obj folder might be generated in a project folder for example) and you deleted the folder in TFS.
Next time you'd build, you'd get an cannot be deleted because it is not empty. error. When triggering the build, you could add the Build.Clean variable as all or source to your next build to fix it. However, since you have multiple agent, only the next agent running will receive that command and clean, and any other builds you make that falls on another agent will fail again because they still have the folder.
Editing the whole build definition so they do a full clean every build would be overkill.
I am of course looking for something else than "Go in the actual folders and delete the folders manually". If it changes anything, the agents aren't hosted, but on premises.
Edit: Logs from the build server, starting with the last cannot be deleted warning:
2017-03-14T20:23:24.2384009Z d:\vso\b1\_work\32\s\[Obfuscated] cannot be deleted because it is not empty.
2017-03-14T20:23:24.4964210Z ##[error]Exit code 1 returned from process: file name 'tf', arguments 'vc get /version:24617 /recursive /overwrite d:\vso\b1\_work\32\s /loginType:OAuth /login:.,******** /noprompt'.
2017-03-14T20:23:24.5124180Z ##[debug]Microsoft.VisualStudio.Services.Agent.ProcessExitCodeException: Exit code 1 returned from process: file name 'tf', arguments 'vc get /version:24617 /recursive /overwrite d:\vso\b1\_work\32\s /loginType:OAuth /login:.,******** /noprompt'.
at Microsoft.VisualStudio.Services.Agent.ProcessInvoker.<ExecuteAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.TfsVCCommandManager.<RunCommandAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.TFCommandManager.<GetAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.TfsVCSourceProvider.<GetSourceAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.BuildJobExtension.<PrepareAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.JobExtensionRunner.<RunAsync>d__30.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.<RunAsync>d__0.MoveNext()
2017-03-14T20:23:24.5174212Z ##[section]Finishing: Get Sources
Ran into this topic through Google.
We have the same scenario and i tried to explain it here too.
Basically how we now fixed it is we created a new build definition that we use to queue new builds with the Build.Clean = all parameter.
So we have a PowerShell script that loops over all AgentsNames we want to clean and queue a new clean build and add the Demand "Agent.Name -equals agentName".
this way your clean build is queued on all agents you want to clean.

Issue on installing a build agent for TFS 2017

I have a stand-alone single server TFS 2017 RTM installation on SQL Express. It is not in any domain, but on my laptop. Have brought it up for my own usage (for learning too). Set it up to run on a self-signed certificate for SSL.
Thought of setting up a vNext build agent on the same machine. I remember somewhere in my brain that build machine should be not in the TFS app tier, to reduce surface attack. Well I don't really bother now about surface attacks. But rather I need a working TFS with build setup as well.
While configuring after entering the URL (https URL), I get prompted for authentication type. I typed Negotiate. After entering credentials, I get below error.
TF400813: Resource not available for anonymous access. Client authentication required.
Upon using Integrated for the authentication type, I get below error.
An error occurred while sending the request.
Failed to connect. Try again or ctrl-c to quit
When I use the http site for URL I get below error for both the authentication types.
Connecting to server ...
Found
Failed to connect. Try again or ctrl-c to quit
I am able to ping to my URL.
Below is the error log from _diag folder.
[2016-11-23 19:53:40Z INFO CredentialManager] Creating type Integrated
[2016-11-23 19:53:40Z INFO CredentialManager] Creating credential type: Integrated
[2016-11-23 19:53:40Z INFO IntegratedCredential] GetVssCredentials
[2016-11-23 19:53:40Z INFO ConfigurationManager] cred retrieved
[2016-11-23 19:53:40Z INFO Terminal] WRITE LINE: Connecting to server ...
[2016-11-23 19:53:41Z INFO CommandSettings] Flag 'unattended': 'False'
[2016-11-23 19:53:41Z ERR Terminal] WRITE ERROR (exception):
[2016-11-23 19:53:41Z ERR Terminal] Microsoft.VisualStudio.Services.WebApi.VssServiceResponseException: Found
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponse(HttpResponseMessage response)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__42`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.VisualStudio.Services.Location.Client.LocationHttpClient.<GetConnectionDataAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.<ConnectAsync>d__41.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.AgentServer.<ConnectAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.ConfigurationManager.<TestConnectAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.ConfigurationManager.<ConfigureAsync>d__7.MoveNext()
Try to disable anonymous authentication and enable windows authentication for your TFS.
Since you set up TFS for your own usage, you can consider using Visual Studio Team Service instead of on-premise TFS. VSTS is free for 5 users.
Try using PAT for the authentication type, and get the personal access token, from the Security page in your profile menu. Using Selected scope - Agent Pools (read, manage)
See http://go.microsoft.com/fwlink/?LinkID=825113
The personal access token is used to register the agent. One final step is suppying the credentials for the Agent Service.
There are a few things that could have gone wrong.
After following Remko's answer and proceeding with "PAT" switch to "Negotiate" method, if you still cant get it working due to "An error occurred while sending the request", it is probably due to certificate issue. In such case, you can simply skip the certificate validation step which happens internally with curl by passing the parameter -sslskipcertvalidaion like below.
./config.sh --sslskipcertvalidation
Here's reference documentation : running agent with self-signed certificate

Resources