在Azure Devops中,我希望yaml管道仅在同一管道的先前执行完成后才执行 [英] In Azure Devops I want my yaml pipeline only to execute after the previous execution of the same pipeline has completed

查看:61
本文介绍了在Azure Devops中,我希望yaml管道仅在同一管道的先前执行完成后才执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试 batch:true 设置描述了

然后编辑服务连接,键入以下屏幕快照中显示的信息.检查

2,添加调用REST API ,检查代理程序池**.

转到"项目设置-> 代理池"下的管道->选择代理池->单击 3点->单击批准并检查..

3,单击" + "->选择调用REST API

4,编辑Invokde Rest API

选择与第一步中创建的azure devop的常规服务连接.

将字段设置如下:

  • URL后缀和参数: _apis/build/builds?definitions =管道的DefinitionId& $ top = 2& queryOrder = queueTimeDescending& api-version = 5.1

  • 成功条件: eq(root ['value'] [1] ['status'],'completed')

请检查

注意:由于Invoke Rest api检查是在代理程序池作用域上设置的.它可能会对其他以该代理程序池为目标的管道产生影响.例如,如果所需的Yaml管道正在等待其先前的运行完成.现在又触发了另一个针对该相同代理程序池的管道,它也必须等待所需的Yaml管道的上一次运行完成.

I tried batch: true setting described here, but it seems to:

  • ignore commits that are pushed when a pipeline is running. I want the last commit to trigger a pipeline after the current run of that pipeline has finished
  • be ignored when you publish directly from CI by pressing build

Has someone found a way to configure a pipeline to run as I have described.

解决方案

You can try adding a Invoke REST API check on the agent pool. The rest api will get the previous build and evaluate its status. So when new build is queued targeting the agent pool. The Invoke REST API will be invoked, this new build will only start when the response of the rest api is evaluated to true.

Please check below steps:

1, create a service connection to your azure devops organization.

Go Project Setting--> Service connections under Pipelines-->Click new service connection--> select Generic to create a generic service connection.

Then Edit the service connection type the information shown in below screenshot. Check here to get a Personal access token.

2, add Invoke REST API check on the agent pool**.

Go Project Setting--> Agent Pools under Pipelines-->Select the agent pool--> Click the 3dots -->Click Approvals and checks. .

3, Click the "+"--> Choose Invoke REST API

4, Edit the Invokde Rest API

Select the generic service connection to your azure devops created in the first step.

Set the fields as below:

  • URL suffix and parameters: _apis/build/builds?definitions=the DefinitionId of your pipeline&$top=2&queryOrder=queueTimeDescending&api-version=5.1

  • Success criteria: eq(root['value'][1]['status'], 'completed')

please check here for more information about build rest api.

Note: Since the Invoke Rest api check is set on agent pool scope. It may have effects on other pipelines that target this agent pool. For example, if the desired yaml pipeline is waiting its previous run to complete. And now another pipeline targeting this same agent pool is triggered, it will have to wait for the previous run of desired yaml pipeline to complete too.

这篇关于在Azure Devops中,我希望yaml管道仅在同一管道的先前执行完成后才执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆