TFS 2013 - 通过电子表格链接工作项目 [英] TFS 2013 - Link Work Items via Spreadsheet
问题描述
我有一个Excel工作表,数百个TFS 2013工作项目ID填充列A和列B.为了说明的目的,我们来说说如下:
列A的第1行到第100行填充了100个Bug工作项的工作项ID / p>
行1 - 列B的行100填充了100个任务工作项的工作项ID。
什么我想做的是有一个自动化的过程,例如一个脚本遍历我的Excel电子表格的一百行,并将列A中的工作项ID与相同行中的列B中的相应工作项ID相关联,例如。将A1中列出的工作项链接到B1,A2到B2,A3到B3等。
我可以看到一个For循环实现这样的要求。
如果将电子表格另存为.csv文件,并具有两列标题父母和孩子然后使用这个优秀的博客文章作为灵感:
http://www.colinsalmcorner.com/post/bulk-migrate-work-item-comments-links-and-attachments
尝试这样:
$ tpcUrl =http:// myserver: 8080 / tfs / MyCollection
/ pre>
$ csvFile =.\map.csv#format:Parent,Child
[Reflection.Assembly] :: LoadWithPartialName('Microsoft.TeamFoundation.Common ')
[Reflection.Assembly] :: LoadWithPartialName('Microsoft.TeamFoundation.Client')
[Reflection.Assembly] :: LoadWithPartialName('Microsoft.TeamFoundation.WorkItemTracking.Client')
$ tpc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollecti onFactory] :: GetTeamProjectCollection($ tpcUrl)
$ wis = $ tpc.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
$ list = Import-Csv $ csvFile
foreach($ map in $ list)
{
$ childWIT = $ wis.GetWorkItem($ map.Child)
写主机创建从Parent的链接:$($ map.Parent)到Child:$($ map.Child)-ForegroundColor Green
$ hierarchyLink = $ wis.WorkItemLinkTypes [[Microsoft.TeamFoundation.WorkItemTracking.Client。 CoreLinkTypeReferenceNames] :: Hierarchy]
$ link = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemLink($ hierarchyLink.ReverseEnd,$ map.Parent)
$ childWIT.WorkItemLinks.Add($ link)
try
{
$ childWIT.Save();
写主机创建链接-ForegroundColor DarkGreen
}
catch
{
写入错误无法保存工作项$ map.Child
写错误$ _
}
}
写主机
写主机链接完成
I would be grateful if I could get some assistance with this.
I have an Excel worksheet with hundreds of TFS 2013 Work Item IDs populating both Column A and Column B. For illustrative purposes, let's just say I have the following:
Row 1 to Row 100 of Column A: Populated with the Work Item IDs of 100 Bug Work Items
Row 1 - Row 100 of Column B populated with the Work Item IDs of 100 Task Work Items.
What I'd like to do is have an automated process, e.g. a script that iterates through the hundred rows of my Excel spreadsheet and link the work item IDs in Column A with the corresponding work item IDs in Column B on the same row, e.g. link the work items listed in A1 to that of B1, A2 to B2, A3 to B3, etc.
I can for instance see a For loop achieving such a requirement. Any help with this would be greatly appreciated please.
解决方案If you save the spreadsheet as a .csv file and have two columns with headings Parent and Child then using this excellent blog post as inspiration:
http://www.colinsalmcorner.com/post/bulk-migrate-work-item-comments-links-and-attachments
Try this:
$tpcUrl = "http://myserver:8080/tfs/MyCollection" $csvFile = ".\map.csv" #format: Parent, Child [Reflection.Assembly]::LoadWithPartialName('Microsoft.TeamFoundation.Common') [Reflection.Assembly]::LoadWithPartialName('Microsoft.TeamFoundation.Client') [Reflection.Assembly]::LoadWithPartialName('Microsoft.TeamFoundation.WorkItemTracking.Client') $tpc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tpcUrl) $wis = $tpc.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore]) $list = Import-Csv $csvFile foreach($map in $list) { $childWIT = $wis.GetWorkItem($map.Child) Write-Host "Creating Link from Parent:$($map.Parent) to Child:$($map.Child)" -ForegroundColor Green $hierarchyLink = $wis.WorkItemLinkTypes[[Microsoft.TeamFoundation.WorkItemTracking.Client.CoreLinkTypeReferenceNames]::Hierarchy] $link = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemLink($hierarchyLink.ReverseEnd, $map.Parent) $childWIT.WorkItemLinks.Add($link) try { $childWIT.Save(); Write-Host "Link created" -ForegroundColor DarkGreen } catch { Write-Error "Could not save work item $map.Child" Write-Error $_ } } Write-Host Write-Host "Linking complete"
这篇关于TFS 2013 - 通过电子表格链接工作项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!