构建代理无法下载可用的工作区
Build agent is unable to download available workspaces
我们最近将 TFS 从 TFS 2015 升级到 TFS 2018。我们将基础架构中的构建代理更改为新代理版本 2.122.1
当开发人员提交他们的变更集或执行计划的构建时,有时构建会按预期处理,但有时我们会在从 TFS 存储库检索源时收到奇怪的错误。
在构建日志中,它们被记录为:
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).
如果我打开代理详细日志,我得到以下信息:
[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\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
代理似乎正在尝试获取可用工作区的列表,但失败了。如果我尝试在计算机的适当权限下执行命令,其中代理是 运行,我会得到正确的工作区列表。
- 尝试使用
system.debug = true
对构建进行排队,您将在日志中获得更多信息。检查日志以获取详细的错误消息。
- 在VS/Team Explorer 中删除构建过程创建的所有工作空间,如以下名称:ws_1_2,并将Get Source 任务中的clean 选项设置为
true
,然后尝试 运行 再次构建。
我终于找到了问题的答案 here。
问题是由缓存的代理信息引起的,当我在构建机器上手动执行 vc workspaces /format:xml /collection:http://servername:8080/tfs/ProjectCollection/ 命令时,有时我会得到工作区列表,但有时我会收到警告和工作区列表(每次调用后结果都不相同,具体取决于缓存使用情况)。由于像
这样的警告
Local path C:\Agent2017_work\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.
代理无法解析 xml 文档,因为它前面有非 sgml 部分。
所以我去了
%LocalAppData%\Microsoft\Team Foundation.0\Cache
目录,删除了缓存内容,问题消失了。
编辑:
替代方法是使用命令
删除缓存的工作空间
tf workspaces /remove:*
我们最近将 TFS 从 TFS 2015 升级到 TFS 2018。我们将基础架构中的构建代理更改为新代理版本 2.122.1
当开发人员提交他们的变更集或执行计划的构建时,有时构建会按预期处理,但有时我们会在从 TFS 存储库检索源时收到奇怪的错误。
在构建日志中,它们被记录为:
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).
如果我打开代理详细日志,我得到以下信息:
[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\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
代理似乎正在尝试获取可用工作区的列表,但失败了。如果我尝试在计算机的适当权限下执行命令,其中代理是 运行,我会得到正确的工作区列表。
- 尝试使用
system.debug = true
对构建进行排队,您将在日志中获得更多信息。检查日志以获取详细的错误消息。 - 在VS/Team Explorer 中删除构建过程创建的所有工作空间,如以下名称:ws_1_2,并将Get Source 任务中的clean 选项设置为
true
,然后尝试 运行 再次构建。
我终于找到了问题的答案 here。
问题是由缓存的代理信息引起的,当我在构建机器上手动执行 vc workspaces /format:xml /collection:http://servername:8080/tfs/ProjectCollection/ 命令时,有时我会得到工作区列表,但有时我会收到警告和工作区列表(每次调用后结果都不相同,具体取决于缓存使用情况)。由于像
这样的警告Local path C:\Agent2017_work\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.
代理无法解析 xml 文档,因为它前面有非 sgml 部分。
所以我去了
%LocalAppData%\Microsoft\Team Foundation.0\Cache
目录,删除了缓存内容,问题消失了。
编辑: 替代方法是使用命令
删除缓存的工作空间tf workspaces /remove:*