如何在 Azure DevOps 中使用 REST API 将工作项 link 转换为拉取请求?
How to link a work item to a pull request using REST API in Azure DevOps?
在发布管道中,使用 REST 创建了一个新的 Pull Requested API。
如何使用 REST link 将特定(已经存在的)工作项添加到合并请求 API?
在当前版本 (DevOps 2019) 中,不支持 link 使用 Pull Request API. (See also related community issue 的工作项。)
使用 PowerShell 以下片段可能会有所帮助。
$requestUri = "$tfsCollectionUri/$teamProject/_apis/wit/workitems/$workItemId" + "?api-version=5.0"
$json = '
[ {
"op": "add", "path": "/relations/-",
"value": {
"rel": "ArtifactLink",
"url": "$pullRequestArtifact",
"attributes": { "name": "pull request" }
}
} ]'
$response = Invoke-RestMethod -Uri $requestUri -UseDefaultCredentials -ContentType "application/json-patch+json" -Method Post -Body $json
注意,需要设置$pullRequestArtifact
。你可以得到它,例如来自 get request.
在发布管道中,使用 REST 创建了一个新的 Pull Requested API。
如何使用 REST link 将特定(已经存在的)工作项添加到合并请求 API?
在当前版本 (DevOps 2019) 中,不支持 link 使用 Pull Request API. (See also related community issue 的工作项。)
使用 PowerShell 以下片段可能会有所帮助。
$requestUri = "$tfsCollectionUri/$teamProject/_apis/wit/workitems/$workItemId" + "?api-version=5.0"
$json = '
[ {
"op": "add", "path": "/relations/-",
"value": {
"rel": "ArtifactLink",
"url": "$pullRequestArtifact",
"attributes": { "name": "pull request" }
}
} ]'
$response = Invoke-RestMethod -Uri $requestUri -UseDefaultCredentials -ContentType "application/json-patch+json" -Method Post -Body $json
注意,需要设置$pullRequestArtifact
。你可以得到它,例如来自 get request.