拉取请求策略 - 构建在另一个拉取请求完成后过期。为其他 PR 自动重新运行过期构建的方法?
Pull request policies - Build expires after another pull request was completed. Way to automatically rerun expired builds for other PRs?
这与 有点相似,但着眼于自动化方面。
我们的背景:我们有保护我们的主分支的拉取请求,每个完成的拉取请求都会使所有其他拉取请求的构建过期,以确保所有剩余拉取请求的构建必须重新排队和构建并正确测试。
现在我们有时会遇到拉取请求争用(我在看着你,冲刺结束!)在这些时候我们有大量的拉取请求打开。虽然我们正在努力尽量减少数量,但有时它会发生。
是否有我缺少的插件或某些功能实际上可以在 PR 自动完成后触发所有那些过期的构建?有一种方法可以自动使所有其他 PR 构建过期,所以我认为也有一种方法可以自动将它们重新排队。我知道这可能会触发构建级联,但我希望我的 PR 尽可能保持最新。
相关 REST API 未记录,但您可以通过 Fiddler 等工具或在 Chrome 浏览器中按 F12 进行跟踪然后 select 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"}}}}}
如您所见,有一些值,例如存储库 ID 和 拉取请求 ID。按照此操作,您应该能够使用 API 为特定的合并请求重新运行 一些构建。
您可以使用 Azure DevOps Services service hooks 或 Rest API 来跟踪拉取请求是否完成,然后使用上面的 API 调用重新 运行 构建。希望这会有所帮助。
这与
我们的背景:我们有保护我们的主分支的拉取请求,每个完成的拉取请求都会使所有其他拉取请求的构建过期,以确保所有剩余拉取请求的构建必须重新排队和构建并正确测试。
现在我们有时会遇到拉取请求争用(我在看着你,冲刺结束!)在这些时候我们有大量的拉取请求打开。虽然我们正在努力尽量减少数量,但有时它会发生。
是否有我缺少的插件或某些功能实际上可以在 PR 自动完成后触发所有那些过期的构建?有一种方法可以自动使所有其他 PR 构建过期,所以我认为也有一种方法可以自动将它们重新排队。我知道这可能会触发构建级联,但我希望我的 PR 尽可能保持最新。
相关 REST API 未记录,但您可以通过 Fiddler 等工具或在 Chrome 浏览器中按 F12 进行跟踪然后 select 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"}}}}}
如您所见,有一些值,例如存储库 ID 和 拉取请求 ID。按照此操作,您应该能够使用 API 为特定的合并请求重新运行 一些构建。
您可以使用 Azure DevOps Services service hooks 或 Rest API 来跟踪拉取请求是否完成,然后使用上面的 API 调用重新 运行 构建。希望这会有所帮助。