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

Ken*_*Yao 30 api powershell tfs bug-tracking

我需要将相同的字段更新为TFS中数百个工作项的相同值.是否有任何方法可以批量执行而不是逐个手动更新?

Ric*_*erg 42

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

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

在此输入图像描述

完整文档: 在Excel中管理工作项(概述页面;内部有很多链接)

您也可以在Web界面中进行批量编辑

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"
Run Code Online (Sandbox Code Playgroud)

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)   
Run Code Online (Sandbox Code Playgroud)