如何在 Azure Build 上重启 ubuntu 代理?

How to restart ubuntu agent on Azure Build?

长话短说,在尝试了几种解决方案 以在 MSBuild 任务没有成功之前终止 VBCSCompiler 之后,我将在收工之前再尝试一个选项,并且只需要坚持 windows2019 代理,即使构建时间将增加三倍。

因此,在 NuGet 恢复任务之后,我需要重新启动 ubuntu 代理(由 Azure Pipelines 代理池托管),我添加了一个命令行任务,但我不确定要为脚本...

我尝试了以下脚本命令sudo reboot

但它没有用(保持 运行 一段时间所以我取消了构建)

我也试过这个命令:

init 6

但是我得到一个错误:

Failed to set wall message, ignoring: Interactive authentication required.
Failed to reboot system via logind: Interactive authentication required.
Failed to open initctl fifo: Permission denied
Failed to talk to init daemon.

这是不可能的,当您重新启动 Hosted Agent 时,您的构建将失败。这就是不允许的原因。