Hai*_*OUI 2 git continuous-integration continuous-deployment azure-devops azure-pipelines
我有一个经典的环境。设置如下:
我有2个分支:Develop和Master。
Azure DevOps中有什么方法可以设置以下规则:
在dev环境(在azure devops的发布管道中定义)上成功部署后,------>将自动创建一个pull request将开发合并到Master中。
或另一个:如果成功执行Build了开发分支-------> 自动
创建一个pull request将开发合并到Master中。
任何帮助将不胜感激。
我刚刚上传了一个扩展程序来做到这一点: https : //marketplace.visualstudio.com/items?itemName=ShaykiAbramczyk.CreatePullRequest
您可以使用Azure DevOps Rest API创建请求请求,因此在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
Run Code Online (Sandbox Code Playgroud)
您需要允许脚本访问OAuth令牌(选中“代理作业”选项中的复选框):
结果:
我将基本参数放在正文中(从分支到分支,标题),但是您可以添加更多参数,例如评论者,请在此处检查文档。