How can an Azure DevOps pipeline agent cleanly reboot itself?

Viewed 2756

We have a Azure Devops pipeline where the agent is running on the app nodes for simplicity. We added a task to the stage to upgrade the .net framework, which requires a reboot. However, when the machine reboots during the deploy, the deploy agent process is killed and the stage fails to complete. The pipeline is aware that a reboot was occurring and it ran one more task on the stage before the reboot occurred during the subsequent task.

Job issues
1 error
1 warning
Operating system is shutting down for computer '(redacted)'

We redeployed the stage and the .net install task detected it was already up-to-date and skipped the reboot and the stage completed successfully this time.

Is there a clean way to create a task to reboot the machine and wait until the reboot completes to resume the stage deployment?

1 Answers

Is there a clean way to create a task to reboot the machine and wait until the reboot completes to resume the stage deployment?

I am afraid there is no such a clean way to create a task to reboot the machine and wait until the reboot completes to resume the stage deployment at this moment.

There is a post Support for Reboot scenarios in Release Management on github about it, but the github-actions bot close it with stale tag. Now the new user voice on our main forum for product suggestions:

Support test signing/reboots in Azure DevOps pipelines

You could vote and add your comment on that post.

Besides, we all know that the agent will be restored to a clean queue after restarting, so it is difficult to continue working on the current agent after restarting

If we use the private agent, we have three workarounds for this request:

  1. The directly way is install the .net framework on the private agent machine directly(If you have a different agent machine, this method may not be suitable).

  2. Use the Auto-redeploy trigger on the Post-deployment conditions:

    enter image description here

  3. Add a Inline powershell task to invoke REST API to re-execute release pipeline before we restart the agent. We need set the demands to use the specify agent, so that the new release pipeline will wait for the agent restart to complete.

Related