简体   繁体   English

Azure 发布管道 - 仅在 VM 可用时运行代理作业

[英]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'}

Get-VM 获取虚拟机

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.

相关问题 当 sourceFolder 包含 Azure 发布管道中的文件夹时,“运行此作业” - "Run this job" when sourceFolder contains a folder in Azure Release Pipeline “Run this job” based on value in angular.json in Azure Release Pipeline - “Run this job” based on value in angular.json in Azure Release Pipeline Azure 发布管道 - 如何设置代理池 - Azure Release Pipeline - How to Set Agent Pool 将 output 传递给 azure 发布管道中的新作业 - Pass output to new job in azure release pipeline 在 Azure DevOps 发布管道中控制作业顺序 - Control Job Order in Azure DevOps Release Pipeline Azure release pipeline Regression test job failure due to error:- 此版本的 ChromeDriver 仅支持 Chrome 版本 86 - Azure release pipeline Regression test job failure due to error :- This version of ChromeDriver only supports Chrome version 86 如何将文件从 Azure 存储复制到管道中代理池中的 VM? - How to copy a file from Azure Storage to a VM in agent pool in a pipeline? 并发管道的概念是什么(Azure Pipeline 中的一个并行作业允许您在任何给定时间运行单个生成或发布作业)? - What is the concept of concurrent pipelines (One parallel job in Azure Pipeline lets you run a single build or release job at any given time)? 如何在Azure发布管道中跨代理作业使用输出变量 - How to use output variables across agent jobs in azure release pipeline Azure DevOps发布管道中缺少“初始化代理”步骤 - 'Initialize Agent' step missing in Azure DevOps release pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM