如何在 devops 上终止进程(最好有超时)

how to kill a process on devops (ideally with a timeout)

我在 yaml 中有一个复杂的 devops 构建脚本。有没有什么方法可以在给定步骤花费太多时间时终止进程(或者执行某些任务会终止某些已处理的进程)。

这对于我们在多个 DLL 中有大型测试套件的情况很有用。我经常看到一些测试失败并且在 devops 挂起之后。我想终止 testrunner 和其他可能挂起(也没有)超时的进程。

这在 devops 上可行吗?

您可以为作业指定 timeoutInMinutescancelTimeoutInMinutes

jobs:
- job: Test
  timeoutInMinutes: 10 # how long to run the job before automatically cancelling
  cancelTimeoutInMinutes: 2 # how much time to give 'run always even if cancelled tasks' before stopping them

更多信息:https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#timeouts