【发布时间】:2018-04-17 09:55:14
【问题描述】:
我们的 TFS 构建代理在 Get Sources 步骤中出现看似随机的问题,其中 git fetch 命令在一个小时后挂起并超时。
日志的最后一部分显示它得到了所需的一切,但决定停止直到超时。
2018-04-12T10:00:11.9145204Z Resolving deltas: 97% (123/126)
2018-04-12T10:00:11.9145204Z Resolving deltas: 99% (125/126)
2018-04-12T10:00:11.9145204Z Resolving deltas: 100% (126/126)
2018-04-12T10:00:11.9145204Z Resolving deltas: 100% (126/126), completed with 17 local objects.
2018-04-12T11:00:03.8383793Z ##[debug]Re-evaluate condition on job cancellation for step: 'Get Sources'.
2018-04-12T11:00:04.1196536Z ##[error]The operation was canceled.
2018-04-12T11:00:04.1352781Z ##[debug]System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at Microsoft.VisualStudio.Services.Agent.ProcessInvoker.<ExecuteAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.GitCommandManager.<ExecuteGitCommandAsync>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.GitCommandManager.<GitFetch>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.GitSourceProvider.<GetSourceAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.Build.BuildJobExtension.<GetSourceAsync>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.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.JobExtensionRunner.<RunAsync>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.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.<RunStepAsync>d__1.MoveNext()
2018-04-12T11:00:04.1352781Z ##[section]Finishing: Get Sources
我们设置了 4 个构建代理,通常在构建期间每晚都有一两个遇到此问题。
当我查看代理的目录并运行 git status 命令时,我收到一条消息:
Rename from 'C:\BuildAgent1\_work\1\s\.git\index.lock' to C:\BuildAgent1\_work\1\s\.git\index' failed. Should I try again? (y/n)
输入“y”只会导致该消息重复。查看 .git/ 文件夹,不存在 index.lock 文件。
手动发布另一个构建,构建通过 Get Sources 步骤没有问题。
为什么在获取所有内容后构建会挂起?
【问题讨论】:
-
只需尝试将 clean 设置为
true并 Clean options 在 Get Sources 下选择Sources directory,然后检查是否有效。跨度> -
我会试一试,看看构建如何更可靠地工作。一些构建定义已经将 clean 选项设置为 true,并且设置了之前失败的源目录选项。
-
您也可以尝试在代理机器上直接删除
.git文件夹下的index和index.lock文件(类似于C:\Agent\_work\2\s\.git)。然后再次检查。您也可以参考this thread进行故障排除。 -
问题是,没有 index.lock 文件。但是从今天的夜间构建来看,在将所有定义更改为 clean 后并没有发生这个特殊问题,因此感谢您的建议。我遇到了另一个(可能不相关的)问题,目前我正在寻求微软的支持。
-
是的,如果
index.lock存在就删除它,如果不只是删除index文件。我在下面发布了解决方案作为答案。您可以检查一下,如果可行,请Accept it as an Answer,这可能对阅读此主题的其他社区成员有所帮助。