我可以得到( www.visualstudio/en-us/docs/integrate/api/git/pull-requests#get-a-pull-request )拉取请求,管理审阅者并完成它。该分支有一个策略要求工作项目,并且它失败,因为拉请求不会自动添加与底层提交相关联的工作项。
在PATCH上拉动拉请求带有错误的参数nets a
您只能更新审阅者,描述,标题,合并状态,和状态 / p>
我可以使用pull requests url + / workitems获得工作项列表,但POST,PUT和PATCH都不支持收集。
我没有看到将工作项与拉取请求相关联的方法吗?
解决方案您可以通过更新工作项链接来将工作项与拉取请求相关联,就像提到的那样。
不确定使用哪种代码语言,我添加了一个C#代码示例供您参考:使用Microsoft.TeamFoundation.Client;
使用Microsoft.TeamFoundation.SourceControl.WebApi; 使用Microsoft.TeamFoundation.WorkItemTracking.WebApi; 使用Microsoft.VisualStudio.Services.WebApi.Patch.Json; 使用Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; namespace PRWIl { class Program { static void Main(string [] args) { string tfsurl =xxx.visualstudio/; TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(tfsurl)); GitHttpClient ghc = ttpc.GetClient< GitHttpClient>(); string project =ProjectName; string repoid =repositoryid; int pullrequestid = 1; int workitemid = 1; GitPullRequest gpr = ghc.GetPullRequestAsync(project,repoid,pullrequestid).Result; WorkItemTrackingHttpClient withc = ttpc.GetClient< WorkItemTrackingHttpClient>(); JsonPatchDocument json = new JsonPatchDocument(); string pullrequesturl =vstfs:/// Git / PullRequestId /+ gpr.Repository.ProjectReference.Id +%2F+ gpr.Repository.Id +%2F+ gpr.PullRequestId ; json.Add(new JsonPatchOperation { Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add, Path =/ relations / - , Value = new WorkItemRelation(){Rel =ArtifactLink,Url = pullrequesturl} }); WorkItem结果= withc.UpdateWorkItemAsync(json,workitemid).Result; } } }
I can get (www.visualstudio/en-us/docs/integrate/api/git/pull-requests#get-a-pull-request) a pull request, manage reviewers and complete it. The branch has a policy requiring work items and it fails as the pull request does not automatically add the work items associated with the underlying commits.
Poking at the PATCH against the pull request with bad parameters nets a
"You can only update reviewers, descriptions, titles, merge status, and status"
I can get a list of work items using the pull requests url + /workitems but POST, PUT and PATCH all are not supported on the collection.
I do not see a way to associate a work item with the pull request?
解决方案You can associate work item to a pull request by updating the work item links just as starain mentioned.
Not sure which code language you use, I added a C# code sample for your reference:
using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.SourceControl.WebApi; using Microsoft.TeamFoundation.WorkItemTracking.WebApi; using Microsoft.VisualStudio.Services.WebApi.Patch.Json; using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; namespace PRWIl { class Program { static void Main(string[] args) { string tfsurl = "xxx.visualstudio/"; TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(tfsurl)); GitHttpClient ghc = ttpc.GetClient<GitHttpClient>(); string project = "ProjectName"; string repoid = "repositoryid"; int pullrequestid = 1; int workitemid = 1; GitPullRequest gpr = ghc.GetPullRequestAsync(project,repoid,pullrequestid).Result; WorkItemTrackingHttpClient withc = ttpc.GetClient<WorkItemTrackingHttpClient>(); JsonPatchDocument json = new JsonPatchDocument(); string pullrequesturl = "vstfs:///Git/PullRequestId/" + gpr.Repository.ProjectReference.Id + "%2F" + gpr.Repository.Id + "%2F" + gpr.PullRequestId; json.Add(new JsonPatchOperation { Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add, Path = "/relations/-", Value = new WorkItemRelation() {Rel = "ArtifactLink", Url = pullrequesturl } }); WorkItem result = withc.UpdateWorkItemAsync(json,workitemid).Result; } } }
更多推荐
以编程方式将工作项目与合并请求相关联
发布评论