Ho bisogno di aggiornare lo stesso campo allo stesso valore per centinaia di workitems in TFS. C'è un modo per farlo in un batch invece di aggiornarli manualmente uno per uno?Come aggiornare in batch più workitems in TFS
30
A
risposta
42
È possibile farlo in Excel:
- Aprire gli elementi di lavoro in Excel, via:
- tasto destro del mouse una query in Team Explorer -> Apri in Excel
- multi- seleziona alcuni elementi di lavoro in un riquadro dei risultati WIT, quindi fai clic con il pulsante destro del mouse -> apri in Excel
- carica Excel, usa Team -> Importa per caricare una query predefinita
- aprire un file * .xls che è già destinata a TFS
- Fai la tua massa modifica
- clic sul pulsante Pubblica sulla barra multifunzione squadra
La documentazione completa: Managing work items in Excel (pagina panoramica; lotti & un sacco di link all'interno)
You can bulk-edit in the web interface too
riga di comando di 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)
0
$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()
}
È possibile scaricare lo script di dettaglio da how to batch update multiple work items in TFS by PowerShell
Richard: potresti farlo anche con il workfile? –
E PowerShell? (So che vuoi abbagliare ancora con il tuo SkillZ Powerhell di nuovo :-)) –
Solo per te, Martin :) –