1

这有点类似于拉取请求策略 - 构建已过期 - 如何再次运行构建?但着眼于自动化方面。

我们的上下文:我们有保护我们的主分支的拉取请求,每个完成的拉取请求都会使所有其他拉取请求的构建过期,以确保所有剩余拉取请求的构建必须重新排队并正确构建和测试。

现在我们有时会出现拉取请求争用(我在看着你,冲刺结束!)在这些时候,我们有很多拉取请求打开。虽然我们正在努力减少数量,但它有时会发生。

是否有一个插件或我缺少的某些功能实际上可以在 PR 自动完成后触发所有这些过期的构建?有一种方法可以自动使所有其他 PR 版本过期,所以我认为还有一种方法可以自动将它们重新排队。我知道这可能会触发构建级联,但我希望我的 PR 尽可能保持最新。

4

1 回答 1

1

相关的 REST API 没有记录,但是您可以通过Fiddler等工具跟踪它或F12在 Chrome 浏览器中按然后选择Network.

如您的问题中所述,在拉取请求页面中手动对构建进行排队。

在此处输入图像描述

例如,使用我的 azure devops 服务,我得到以下 API

Post https://dev.azure.com/patricklu/_apis/Contribution/dataProviders/query/project/a72e1ef5-4921-49c5-9260-e72b7bff977d

请求正文:

{"contributionIds":["ms.vss-code-web.pull-request-detail-policy-data-provider"],"context":{"properties":{"repositoryId":"357893bf-9a1f-4ee4-95d3-c5ceda4f4abc","pullRequestId":12,"policyEvaluationIds":["bca44f9f-268f-4640-aa7e-af5253b3b11e"],"pageSource":{"contributionPaths":["VSS","VSS/Resources","q","knockout","mousetrap","mustache","react","react-dom","react-transition-group","jQueryUI","jquery","OfficeFabric","tslib","@uifabric","VSSUI","ContentRendering","ContentRendering/Resources","TFSUI","TFSUI/Resources","WidgetComponents","WidgetComponents/Resources","Charts","Charts/Resources","TFS","Notifications","Presentation/Scripts/marked","Presentation/Scripts/URI","Presentation/Scripts/punycode","Presentation/Scripts/IPv6","Presentation/Scripts/SecondLevelDomains","highcharts","highcharts/highcharts-more","highcharts/modules/accessibility","highcharts/modules/heatmap","highcharts/modules/funnel","Analytics"],"diagnostics":{"sessionId":"8277adc6-6810-4cf9-b984-10860e90c0b5","activityId":"8277adc6-6810-4cf9-b984-10860e90c0b5","bundlingEnabled":true,"cdnAvailable":true,"cdnEnabled":true,"webPlatformVersion":"M156","serviceVersion":"Dev17.M156.1 (build: AzureDevOps_M156_20190821.17)"},"navigation":{"topMostLevel":8,"area":"","currentController":"Apps","currentAction":"ContributedHub","currentParameters":"12","commandName":"Git.pullrequest","routeId":"ms.vss-code-web.pull-request-review-route","routeTemplates":["{project}/{team}/_git/{GitRepositoryName}/pullrequest/{parameters}","{project}/_git/{GitRepositoryName}/pullrequest/{parameters}","_git/{project}/pullrequest/{parameters}"],"routeValues":{"project":"GITAgile","parameters":"12","controller":"Apps","action":"ContributedHub","vctype":"git","viewname":"pull-request-review"}},"project":{"id":"a72e1ef5-4921-49c5-9260-e72b7bff977d","name":"GITAgile"},"selectedHubGroupId":"ms.vss-code-web.code-hub-group","selectedHubId":"ms.vss-code-web.pull-request-hub","url":"https://dev.azure.com/patricklu/_git/GITAgile/pullrequest/12?_a=overview"},"sourcePage":{"url":"https://dev.azure.com/patricklu/_git/GITAgile/pullrequest/12?_a=overview","routeId":"ms.vss-code-web.pull-request-review-route","routeValues":{"project":"GITAgile","parameters":"12","controller":"Apps","action":"ContributedHub","vctype":"git","viewname":"pull-request-review"}}}}}

在此处输入图像描述

如您所见,有一些值,例如 repository ID 和pull Request ID。按照这个,您应该能够使用 API 为特定的拉取请求重新运行一些构建。

您可以使用Azure DevOps Services 服务挂钩或 Rest API 来跟踪拉取请求是否完成,然后使用上述 API 调用重新运行构建。希望这可以帮助。

于 2019-08-28T09:28:54.270 回答