如何在Azure DevOps中使用REST API将工作项链接到拉取请求? [英] How to link a work item to a pull request using REST API in Azure DevOps?

查看:54
本文介绍了如何在Azure DevOps中使用REST API将工作项链接到拉取请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在发布管道中,使用REST API创建了新的请求请求.

Within a release pipeline a new Pull Requested is created using REST API.

如何使用REST API将特定的(已经存在的)工作项链接到拉取请求"?

How to link a specific (already existing) Work Item to the Pull Request using REST API?

在当前版本(DevOps 2019)中,不支持使用

In the current version (DevOps 2019) it is not supported to link Work Items using Pull Request API. (See also related community issue.)

推荐答案

使用PowerShell以下代码片段可能会有所帮助.

Using PowerShell the following snipped may help.

$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 .你可以得到它例如来自

Note, $pullRequestArtifact needs to be set. You can get it e.g. from get request.

这篇关于如何在Azure DevOps中使用REST API将工作项链接到拉取请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆