2016-01-29 80 views
1

我們正在使用TFS 2015和CMMI過程模板。在TFS 2015中複製工作項目

我想了解如何從發佈工作項目創建完整副本,從而使目標工作項目類型成爲需求。 提供完整副本,我的意思是應該複製在需求(例如標題,描述,狀態,區域路徑,迭代,...)中的問題所有領域的值以及所有到其他工作的鏈接項目(孩子,父母,相關人員,繼任人員,前任等)。

在VSO中使用「複製」將f.e.不復制問題(任務)的子鏈接。相反,它創建一個「相關」的來源問題...

任何建議如何實現這一點將不勝感激。

回答

0

您可以使用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(); 
     } 
    } 
} 
1

當您選擇「創建工作項的副本」,VSO不能確定源工作項目和目標工作項之間的關係,所以它只是製造「相關」的關係它們之間。工作項目被複制後,您可以手動更新它。您還可以提交User Voice用於在「複製工作項」對話框中添加關係選擇選項。

現在,自動執行此操作的方法是使用TFS API或VSO Rest API來讀取和記錄有關源工作項的詳細信息,更改所需信息(工作項類型,關係),然後創建一個基於新信息的新工作項目。