[英]Azure Release Pipeline - Only run agent job if VM is available
I would like to create an agent job task in an Azure Release Pipeline , which will only run if the affected VM is up and running.我想在Azure Release Pipeline中创建一个代理作业任务,该任务仅在受影响的 VM 启动并运行时运行。 I had a peek into the 'Azure Pipeline Conditions' , but it seems there is no such thing as 'checking for server status' .我查看了“Azure 管道条件” ,但似乎没有“检查服务器状态”之类的东西。 Also did not found a Task Template for checking the VM status.也没有找到用于检查 VM 状态的任务模板。 Therefore I cannot create an Output Variable beforehand and use THIS in a condition.因此,我无法事先创建Output 变量并在条件下使用 THIS。 Thanks a lot in advance!提前非常感谢!
BR Denis BR丹尼斯
Azure Release Pipeline - Only run agent job if VM is available Azure 发布管道 - 仅在 VM 可用时运行代理作业
Indeed, just as you know that, there is not such condition or task to check the VM status at this moment.确实,正如您所知,目前没有这样的条件或任务来检查 VM 状态。
As workaround, we could create a scripts to check the VM status, like powershell:作为解决方法,我们可以创建一个脚本来检查 VM 状态,例如 powershell:
PS C:\> Get-VM -ComputerName Server1 | Where-Object {$_.State -eq 'Running'}
Then, sets variable with different value based on the VM status:然后,根据 VM 状态设置具有不同值的变量:
Write-Output "##vso[task.setvariable variable=VMIsRunning]True"
OR或者
Write-Output "##vso[task.setvariable variable=VMIsRunning]Flase"
And add custom conditions in the next steps in the build pipeline:并在构建管道的后续步骤中添加自定义条件:
and(succeeded(), eq(variables['VMIsRunning'], 'True'))
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.