如何清理多个构建代理程序上的源代码

时间:2017-03-17 14:40:24

标签: tfs azure-devops azure-pipelines

假设您已经配置了多个构建代理,并且构建代理上有一个文件夹,其中包含一些不是来自TFS的内容(甚至指定输出,可能会在项目中生成某些中间内容,如obj文件夹)例如文件夹)并删除了TFS中的文件夹。

下次构建时,会出现cannot be deleted because it is not empty.错误。触发构建时,您可以将Build.Clean变量allsource添加到下一个版本中以进行修复。但是,由于您有多个代理程序,因此只有正在运行的下一个代理程序才会收到该命令并进行清理,而您所做的任何其他代理程序将再次失败,因为它们仍然具有该文件夹。

编辑整个构建定义,以便它们完全清理每个构建都是过度的。

我当然正在寻找“进入实际文件夹并手动删除文件夹”之外的其他内容。如果它发生了任何变化,则代理不会托管,而是在内部。

编辑:从构建服务器开始记录,从上一个cannot be deleted警告开始:

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

1 个答案:

答案 0 :(得分:1)

通过Google进入此主题。 我们有相同的场景,我也尝试解释它here

基本上我们现在如何修复它是因为我们创建了一个新的构建定义,我们用它来使用Build.Clean = all参数对新构建进行排队。

因此,我们有一个PowerShell脚本,它遍历我们要清理的所有AgentsNames并为新的干净构建排队并添加Demand“Agent.Name -equals agentName”。 这样,您的干净构建就会排在要清理的所有代理上。