gpt4 book ai didi

git - CI/CD 管道 Azure devops 部署发布后自动 merge

转载 作者:太空狗 更新时间:2023-10-29 14:31:00 26 4
gpt4 key购买 nike

我有一个经典的环境。设置如下:

我有 2 个分支:DevelopMaster

在 Azure DevOps 中是否有任何方法可以设置以下规则:

  1. 在开发环境(定义在azure devops 的发布管道)------> 自动创建一个pull request merge developMaster.

  2. 或另一个:如果 develop 分支Build 成功--------> 自动创建一个pull request merge develop into Master

我们将不胜感激。

最佳答案

编辑:

我刚刚上传了一个扩展程序: https://marketplace.visualstudio.com/items?itemName=ShaykiAbramczyk.CreatePullRequest


您可以使用 Azure DevOps Rest API创建一个 Pull Request,所以在 Build/Release 的末尾添加一个 PowerShell 任务来执行它,例如:

$body =  @{
sourceRefName= "$(Build.SourceBranch)"
targetRefName = "refs/heads/master"
title = "PR from Pipeline"
}

$head = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }
$json = ConvertTo-Json $body
$url = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullrequests?api-version=5.0"
Invoke-RestMethod -Uri $url -Method Post -Headers $head -Body $json -ContentType application/json

Photo3

您需要允许脚本访问 OAuth token (选中代理作业选项中的复选框):

Photo1

结果:

enter image description here

我将基本参数放在主体中(从分支、到分支、标题),但您可以添加更多参数,如审阅者,查看文档 here .

关于git - CI/CD 管道 Azure devops 部署发布后自动 merge ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56184170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com