如何批量更新TFS中的多个工作项

发布于 2024-07-30 15:07:18 字数 59 浏览 1 评论 0原文

我需要将 TFS 中数百个工作项的相同字段更新为相同值。 有没有什么方法可以批量更新而不是手动更新呢?

I need to update same field to same value for hundreds of workitems in TFS. Is there any way to do it in a batch instead of updating them manually one by one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

﹏雨一样淡蓝的深情 2024-08-06 15:07:19

您可以在 Excel 中执行此操作:

  1. 通过以下方式在 Excel 中打开工作项:
    • 右键单击团队资源管理器中的查询 -> 在 Excel 中打开
    • 在 WIT 结果窗格中多选一些工作项,然后右键单击 -> 在 Excel 中打开
    • 加载 Excel,使用 Team -> 导入以加载预定义查询
    • 打开已绑定到 TFS 的 *.xls 文件
  2. 进行批量编辑
  3. 单击团队功能区上的“发布”按钮

在此处输入图像描述

完整文档:
在 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)   

You can do this in Excel:

  1. Open the work items in Excel, via:
    • right click a query in Team Explorer -> open in Excel
    • multi-select some work items in a WIT result pane, then right click -> open in Excel
    • load Excel, use Team -> Import to load a predefined query
    • open a *.xls file that is already bound to TFS
  2. Make your bulk edits
  3. Click the Publish button on the Team ribbon

enter image description here

Full documentation:
Managing work items in Excel (overview page; lots & lots of links inside)

You can bulk-edit in the web interface too

Windows command line:

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)   
回忆凄美了谁 2024-08-06 15:07:19
$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()
}

您可以从 如何批量更新 TFS 中的多个工作项下载详细脚本PowerShell

$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()
}

You can download detail script from how to batch update multiple work items in TFS by PowerShell

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文