代码中的C#TFS拉取请求更新任务

时间:2018-07-24 06:21:37

标签: c# pull-request tfs2017

是否有一种方法可以在请求请求时自动将带有C#代码(使用Microsoft TeamFoundation插件)的任务从“代码审查”移动到“完成”?

如果可能的话,有人可以指出我正确的方向吗?

谢谢

1 个答案:

答案 0 :(得分:0)

You can get the PR programmatically in this way:

// for VSTS    
var connection = new VssConnection(collectionUri, credentials);
// for TFS On-Premise
var connection  = new TfsTeamProjectCollection(_serverUrl);
int pullRequestId = 11;
var client = connection.GetClient<GitHttpClient>();
var pr = await client.GetPullRequestByIdAsync(pullRequestId);

Now you have th PR on your hand... you can check the status with the property pr.Status.

Note: maybe you need the reference Microsoft.TeamFoundation.SourceControl.WebApi.