有没有办法从命令行获取tfs 2010 teambuild的控制器(和代理)状态?我的控制器(已经有大约20个)继续不得不重新启动(我们知道为什么会这样)并且我想要一种运行脚本(psexec?)来检查什么是熬夜的方法。干杯
答案 0 :(得分:2)
可以使用一个小型控制台应用程序为您执行此操作,如下所示:
using System;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;
namespace GetAgentsStatus
{
class Program
{
static void Main()
{
TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("CollectionUri"));
IBuildServer buildService = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));
IBuildController buildController = buildService.GetBuildController("BuildControllerName");
foreach (var agent in buildController.Agents)
{
if(agent.Status == AgentStatus.Offline || agent.Status == AgentStatus.Unavailable)
{
Console.WriteLine(string.Format("{0} needs restarting",agent.Name));
}
}
}
}
}
如果您打开任何构建定义进行编辑,请导航至“构建默认值”以检索BuildControllerName
的值