如何批次更新多个工作项目在TFS
-
06-07-2019 - |
题
我需要更新相同的领域,以同样的价值数百的工作项目在TFS。是否有任何方式做到这一批中而不是更新他们的手一个个的?
解决方案
你可以这样做 Excel:
- 打开工作的项目,在Excel中,通过:
- 右击中的查询团队资源管理->在Excel中打开
- 多选择中的一些工作项目,在一个智慧的结果格,然后右击->在Excel中打开
- 负载的Excel、使用团队->的进口到负荷的一个预先定义的查询
- 打开*.xls文件,是已经开TFS
- 让你的批量编辑
- 击布按钮队上的丝带
完整的文件:管理工作的项目,在Excel (概览网页;很多&许多链接的内部)
Windows命令行:
REM make Martin Woodward fix all my bugs
tfpt query /format:id "TeamProject\public\My Work Items" |
tfpt workitem /update @ /fields:"Assigned To=Martin"
Powershell:
# make Bill & Steve happy
$tfs = tfserver -path . -all
$items = $tfs.wit.Query("
SELECT id FROM workitems
WHERE [Created By] IN ('bill gates', 'steve ballmer')") |
% {
$_.Open()
$_.Fields["priority"].value = 1
$_
}
# note: this will be much faster than tfpt since it's only one server call
$tfs.wit.BatchSave($items)
其他提示
$secpasswd = ConvertTo-SecureString $TfsPasswd -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($TfsUserName, $secpasswd)
Connect-TfsTeamProjectCollection -Server $TfsServerUrl -Collection $TfsCollection -Credential $mycreds
#Get-TfsTeamProject
Connect-TfsTeamProject -Project $TfsProjectName
$workItems = Get-TfsWorkItem -Filter "[System.WorkItemType] = 'Bug' AND [System.AssignedTo] = '$TfsUserName'"
foreach ($workItem in $workItems)
{
$tpc = $workItem.Store.TeamProjectCollection
$id = $workItem.Id
$store = $tpc.GetService([type]'Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore')
$wi = $store.GetWorkItem($id)
$projectName = $wi.Project.Name
foreach($fldName in $Fields.Keys)
{
$wi.Fields[$fldName].Value = $Fields[$fldName]
}
$wi.Save()
}
不隶属于 StackOverflow