我正在尝试使用我的存储库中的链接分支更新 azure devops 中的工作项。我正在使用 azure-devops-node-api。目前我正在尝试更新“关系”字段,但我不确定那是否正确。
if (linkUrl) {
azureUpdateArr.push({
op: "add",
path: "/relations/-",
value: {
rel: "ArtifactLink",
url: linkUrl,
attributes: {
name: "Branch",
comment: "Making a new link for the branch",
},
},
});
}
await api.updateWorkItem({}, azureUpdateArr, Number(workItem.Number));
azureUpdateArr
是一个 json 补丁文档,所以我只是尝试添加一个操作来添加关系,但我不确定 rel:
是什么应该是,或者实际上是其他任何东西。
最佳答案
i'm not sure what the rel: should be, or indeed anything else.
根据我的测试,如果需要将 git 分支链接到工作项,rel
类型为 ArtifactLink
。
如代码所示,rel
可能是正确的。
我引用了这个关于Rest API的文档:Work Items - Update 。
这是我的请求正文示例:
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "ArtifactLink",
"url": "vstfs:///Git/Ref/{Project ID}/{Repo ID}/GB{Branch name}",
"attributes": {
"name": "Branch",
"comment": "test link branch"
}
}
}
结果:
注意:url字段需要使用GB+Branch name
格式。或者好像分支无法链接成功。
希望这有帮助。
关于node.js - 如何使用 Node api 在 azure devops 工作项和 git 分支之间添加链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62387680/