拉取请求策略-构建在另一个拉取请求完成后过期。自动重新运行其他PR的过期版本的方法?

时间:2019-08-27 11:44:54

标签: tfs tfs2019

这与Pull request policies - Build expired - How can I run the build again?有点相似,但着眼于自动化方面。

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

现在,在某些时候,我们会有很多请求请求(我在看着你,冲刺结束!)。在我们努力减少数量的同时,有时它只是发生。

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

1 个答案:

答案 0 :(得分:1)

未记录相关的REST API,但是您可以使用Fiddler之类的工具对其进行跟踪,也可以在Chrome浏览器中按 F12 然后选择Network

在拉取请求页面中,按照问题中的说明手动将构建排队。

enter image description here

例如,通过我的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"}}}}}

enter image description here

如您所见,其中包含一些值,例如存储库ID和拉请求ID 。遵循此步骤,您应该能够使用API​​来为特定的“拉取请求”重新运行一些构建。

您可以使用Azure DevOps Services service hooks或Rest API来跟踪请求请求是否完成,然后使用上述API调用重新运行构建。希望这会有所帮助。

相关问题