【问题标题】:Copying Work Items in TFS 2015在 TFS 2015 中复制工作项
【发布时间】:2016-05-07 11:21:23
【问题描述】:
我们正在使用 TFS 2015 和 CMMI 流程模板。
我正在尝试了解如何从问题工作项创建完整副本,其中目标工作项类型应为要求。
对于完整副本,我的意思是在需求中也可用的问题的所有字段的值(例如标题、描述、状态、区域路径、迭代......)以及指向其他工作项的所有链接都应该被复制(子、父、相关、继任者、前任者等)。
在 VSO 中使用“复制”将 f.e.不要复制问题(任务)的子链接。相反,它会创建一个与源问题“相关”...
任何如何实现这一点的建议都将受到高度赞赏。
【问题讨论】:
标签:
tfs
azure-devops
tfs-workitem
【解决方案1】:
您可以使用TFS API 从 TFS 读取测试用例,然后根据您希望复制的属性创建一个新的测试用例。这是creating a Test Case的一些示例代码:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace WorkItemTrackingSample
{
class Program
{
static void Main(string[] args)
{ // Connect to the server and the store, and get the WorkItemType object
// for user stories from the team project where the user story will be created.
Uri collectionUri = (args.Length < 1) ?
new Uri("http://server:port/vdir/DefaultCollection") : new Uri(args[0]);
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["DinnerNow"];
WorkItemType workItemType = teamProject.WorkItemTypes["Test Case"];
// Create the work item.
WorkItem userStory = new WorkItem(workItemType)
{
// The title is generally the only required field that doesn’t have a default value.
// You must set it, or you can’t save the work item. If you’re working with another
// type of work item, there may be other fields that you’ll have to set.
Title = "Recently ordered menu",
Description =
"As a return customer, I want to see items that I've recently ordered."
};
// Save the new user story.
userStory.Save();
}
}
}
【解决方案2】:
当您选择“创建工作项的副本”时,VSO 无法确定源工作项和目标工作项之间的关系,因此它只是在它们之间创建“相关”关系。您可以在复制工作项后手动更新它。您还可以提交User Voice 以在“复制工作项”对话框中添加关系选择选项。
目前,自动执行此操作的方法是使用 TFS API 或 VSO Rest API 读取和记录有关源工作项的详细信息,更改您想要的信息(工作项类型、关系),然后创建一个新的基于新信息的工作项。