TFS内のイテレーションを外部システムにリンクして、会社全体のプロジェクトを追跡しています。以前は、TFSプロジェクトでIterationPathを使用してリンクしていましたが、問題は、プロジェクトの進行に伴ってこれらのIterationPathの名前が変更され、リンクが失われることです。そこで、調べてみたところ、IterationIDを使ってリンクすることを考えています。TFSWarehouseのIterationIDは、WorkItemTrackingテーブルのIterationIDと同じではありません。また、IterationPathのIterationIDを見つける簡単な方法が見つからないようです。誰かが私たちがこれをどのように達成できるかについて何か考えを持っていますか?
4 に答える
OK-さらに掘り下げた後、すべての反復を反復する以下のコードを見つけたので、これのサブセットを使用して、必要なものを取得します:)
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace TFSIterationList
{
class Program
{
static void Main(string[] args)
{
string tfsServer = "tfs";
string tfsProject = "Project Name";
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsServer);
WorkItemStore store = new WorkItemStore(tfsServer);
PrintTreeNodeCount(store, tfsProject);
}
private static void PrintTreeNodeCount(WorkItemStore store, string tfsProject)
{
int iterationNodeCount = 0;
NodeCollection rootNodeCollection = store.Projects[tfsProject].IterationRootNodes;
GetChildNodeCount(rootNodeCollection, ref iterationNodeCount);
Console.WriteLine(tfsProject + " Iteration nodes : " + iterationNodeCount);
}
private static void GetChildNodeCount(NodeCollection nodeCollection, ref int nodeCount)
{
nodeCount += nodeCollection.Count;
for (int i = 0; i < nodeCollection.Count; i++)
{
Console.WriteLine(nodeCollection[i].Id + " : " + nodeCollection[i].Path);
// Console.WriteLine(nodeCollection[i].Name);
if (nodeCollection[i].ChildNodes.Count > 0)
{
// Recursively walk through the child nodes
GetChildNodeCount(nodeCollection[i].ChildNodes, ref nodeCount);
}
}
}
}
}
すべての TFS エリアを印刷する場合は、次の行を変更します。
from: NodeCollection rootNodeCollection = store.Projects[tfsProject].IterationRootNodes;
to: NodeCollection rootNodeCollection = store.Projects[tfsProject].AreaRootNodes;
コードをありがとう、それは私の最後に役に立ちました。
これは、Work Item Query Language ( MSDN の WIQL ) を使用して実現することもできます。
WIQL を使用すると、TFS に対してクエリを実行できます。私は C# を使用しましたが、これはほとんどまたはすべての .NET 言語で機能すると思います。
WorkItemStore workItemStore = (WorkItemStore)projectCollection.GetService(typeof(WorkItemStore));
WorkItemCollection queryResults = workItemStore.Query(
"Select [System.IterationID], [System.IterationPath] " +
"From WorkItems ORDER BY [System.IterationID]");
クエリ文字列に where 句を追加することで、特定の iterationID を見つけることができます。
+ " Where [System.IterationPath] = 'Path'");
queryResults は、それらを反復することで表示できます。
foreach (WorkItem workitem in queryResults)
{
Console.WriteLine(workitem.IterationID);
}
これには、最新の TFS Power Tools の powershell スナップインを使用します。
> $tfs = Get-TfsServer <name> -all
> $tfs.WIT.Projects | % { $_.IterationRootNodes } | ft -auto id, path
Id Path
-- ----
100 Test-ConchangoV2\Release 1\Sprint 1
92 Test-ConchangoV2\Release 1\Sprint 2
97 Test-ConchangoV2\Release 1\Sprint 3
91 Test-ConchangoV2\Release 1\Sprint 4
94 Test-ConchangoV2\Release 1\Sprint 5
93 Test-ConchangoV2\Release 1\Sprint 6
96 Test-ConchangoV2\Release 2\Sprint 1
90 Test-ConchangoV2\Release 2\Sprint 2
98 Test-ConchangoV2\Release 2\Sprint 3
99 Test-ConchangoV2\Release 3\Sprint 1
95 Test-ConchangoV2\Release 3\Sprint 2
89 Test-ConchangoV2\Release 3\Sprint 3