You can create the Pull Request through Pull Request REST API during the release.
There is Invoke HTTP REST API task but may not good for your requirement.
The simple way is that you can do it through PowerShell task:
- Select the phase (e.g. Run on agent) and check Allow scripts to access OAuth token option. You can use Personal Access Token too.
- Add PowerShell task
Simple sample:
param(
[string]$project,
[string]$repo,
[string]$sourceBranch,
[string]$targetBranch,
[string]$title,
[string]$des,
[string]$token
)
$bodyObj=@{
"sourceRefName"="refs/heads/$sourceBranch";
"targetRefName"= "refs/heads/$targetBranch";
"title"= "$title";
"description"="$des";
}
$bodyJson=$bodyObj| ConvertTo-Json
$uri="https://XXX.visualstudio.com/DefaultCollection/$project/_apis/git/repositories/$repo/pullRequests?api-version=3.0"
Write-Output $bodyJson
Write-Output $uri
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "test",$token)))
$result= Invoke-RestMethod -Method POST -Uri $Uri -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $bodyJson
Arguments: -project "XXX" -repo "XXX" -sourceBranch "XX" -targetBranch "XX" -title "XX" -des "XX" -token [$(System.AccessToken) or personal access token]