TFS2017:通过api创建代码审查请求

时间:2018-07-06 06:30:00

标签: c# tfs2017 tfs-sdk

是否可以使用.NET在变更集上创建完整的Code Review Request(通过Visual Studio Team Explorer->工作,并通过电子邮件发送给能够评论变更的审阅者)。库Microsoft.TeamFoundationServer.Client

P.S。通过我的研究,我知道使用Discussion ServiceMicrosoft.TeamFoundationServer.ExtendedClient似乎是可行的,但是我正在寻找使用“新” API的解决方案。

1 个答案:

答案 0 :(得分:0)

您可以通过创建代码审查请求工作项来启动代码审查(使用常规WIT api创建此类WIT)。通过REST API进行代码审查,并查看创建的代码审查请求工作项,以了解如何设置字段。例如:

POST http://tfs2017:8080/tfs/DefaultCollection/{TeamProject}/_apis/wit/workitems/$Code%20Review%20Request?api-version=3.2

Content-Type: application/json-patch+json

  [
  {
    "op": "add",
    "path": "/fields/System.Title",
    "from": null,
    "value": "codereview452"
  },
  {
    "op": "add",
    "path": "/fields/System.State",
    "from": null,
    "value": "Requested"
  },
  {
    "op": "add",
    "path": "/fields/System.Reason",
    "from": null,
    "value": "New"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.CodeReview.ContextType",
    "from": null,
    "value": "Changeset"
  },
   {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.CodeReview.Context",
    "from": null,
    "value": "452"
  },
   {
    "op": "add",
    "path": "/fields/System.AssignedTo",
    "from": null,
    "value": "xxxx"
  },
   {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.Common.StateCode",
    "from": null,
    "value": "0"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.CodeReview.ContextCode",
    "from": null,
    "value": "2"
  }
]

对代码审查的实际评论需要使用讨论服务。