在 TFS 2015 中复制工作项
Copying Work Items in TFS 2015
我们使用的是 TFS 2015 和 CMMI 过程模板。
我正在尝试了解如何从问题工作项创建完整副本,其中目标工作项类型应为需求。
对于完整副本,我的意思是在需求中也可用的问题的所有字段的值(例如标题、描述、状态、区域路径、迭代......)应该被复制以及到其他工作项的所有链接(child、parent、相关、继任者、前任等)。
在 VSO 中使用 "Copy" 将 f.e。不复制问题(任务)的 child 链接。相反,它会创建一个 "related" 到源 Issue...
如有任何实现方法的建议,我们将不胜感激。
您可以使用 TFS API to read a test cases from TFS and then create a new one based on the properties you wish to copy over. Here is some sample code for 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();
}
}
}
当您 select "Create copy of work item" 时,VSO 无法确定源工作项和目标工作项之间的关系,因此它只是在它们之间创建 "Related" 关系。您可以在复制工作项后手动更新它。您还可以提交 User Voice 以在 "Copy Workitem" 对话框中添加关系 select 选项。
目前,自动执行此操作的方法是使用 TFS API 或 VSO Rest API 读取并记录有关源工作项的详细信息,更改您想要的信息(工作项类型、关系),然后根据新信息创建新的工作项。
我们使用的是 TFS 2015 和 CMMI 过程模板。
我正在尝试了解如何从问题工作项创建完整副本,其中目标工作项类型应为需求。 对于完整副本,我的意思是在需求中也可用的问题的所有字段的值(例如标题、描述、状态、区域路径、迭代......)应该被复制以及到其他工作项的所有链接(child、parent、相关、继任者、前任等)。
在 VSO 中使用 "Copy" 将 f.e。不复制问题(任务)的 child 链接。相反,它会创建一个 "related" 到源 Issue...
如有任何实现方法的建议,我们将不胜感激。
您可以使用 TFS API to read a test cases from TFS and then create a new one based on the properties you wish to copy over. Here is some sample code for 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();
}
}
}
当您 select "Create copy of work item" 时,VSO 无法确定源工作项和目标工作项之间的关系,因此它只是在它们之间创建 "Related" 关系。您可以在复制工作项后手动更新它。您还可以提交 User Voice 以在 "Copy Workitem" 对话框中添加关系 select 选项。
目前,自动执行此操作的方法是使用 TFS API 或 VSO Rest API 读取并记录有关源工作项的详细信息,更改您想要的信息(工作项类型、关系),然后根据新信息创建新的工作项。