通过 API 获取有关 Web 样式构建的信息
Obtaining Information About Web Style Builds via the API
我们正在转向基于 TFS 2015(更新 4)的 Web 风格构建。
我一直能够使用下面的代码检索有关构建的信息,但这并不能检索我们通过网络界面创建的新构建。
是否有合理的方法来修改我的代码以同时引入旧版和新式版?
如果没有,我想是时候弄清楚如何使用 REST API 了。对于等效查询的任何提示,我们将不胜感激。
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://SERVERINFO"));
IBuildServer buildServer = (IBuildServer) tfs.GetService(typeof (IBuildServer));
var buildDetail = buildServer.CreateBuildDetailSpec("*");
buildDetail.MinFinishTime = DateTime.Now.Date.AddDays(-1);
buildDetail.InformationTypes = null;
buildDetail.QueryDeletedOption = QueryDeletedOption.IncludeDeleted;
buildDetail.MaxBuildsPerDefinition = 1; //Only return the most recent of each build type...or comment out to return all builds with this definition
var builds = buildServer.QueryBuilds(buildDetail).Builds.Select(....
旧 XAML 构建系统使用 SOAP API。基于任务的新 vNet 构建系统没有 SOAP API.它正在使用 REST API。恐怕你不能只修改代码来获得新版本。他们不支持 Build vNext,因为它们是在他们的时代之前编写的。
除了 SOAP API 正在慢慢被 REST API 取代,特别是在一些新的 features.Since 中,您正在转向基于 TFS2015 update4 的 vNext 构建。强烈建议您使用 Rest API.
您可以通过查询 REST API directly or by using the Team Foundation Server Client NuGet package 从 C# 代码访问它。 样本:
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Build.WebApi;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Uri tfsurl = new Uri("http://xxxx:8080/tfs/CollectionName");
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(tfsurl);
BuildHttpClient bhc = ttpc.GetClient<BuildHttpClient>();
List<Build> builds = bhc.GetBuildsAsync("ProjectName").Result;
foreach (Build bu in builds)
{
Console.WriteLine(bu.BuildNumber);
}
Console.ReadLine();
}
}
}
通过使用上述库中的 Rest API,您可以获得 XAML 和 vNext 构建。
我们正在转向基于 TFS 2015(更新 4)的 Web 风格构建。
我一直能够使用下面的代码检索有关构建的信息,但这并不能检索我们通过网络界面创建的新构建。
是否有合理的方法来修改我的代码以同时引入旧版和新式版?
如果没有,我想是时候弄清楚如何使用 REST API 了。对于等效查询的任何提示,我们将不胜感激。
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://SERVERINFO"));
IBuildServer buildServer = (IBuildServer) tfs.GetService(typeof (IBuildServer));
var buildDetail = buildServer.CreateBuildDetailSpec("*");
buildDetail.MinFinishTime = DateTime.Now.Date.AddDays(-1);
buildDetail.InformationTypes = null;
buildDetail.QueryDeletedOption = QueryDeletedOption.IncludeDeleted;
buildDetail.MaxBuildsPerDefinition = 1; //Only return the most recent of each build type...or comment out to return all builds with this definition
var builds = buildServer.QueryBuilds(buildDetail).Builds.Select(....
旧 XAML 构建系统使用 SOAP API。基于任务的新 vNet 构建系统没有 SOAP API.它正在使用 REST API。恐怕你不能只修改代码来获得新版本。他们不支持 Build vNext,因为它们是在他们的时代之前编写的。
除了 SOAP API 正在慢慢被 REST API 取代,特别是在一些新的 features.Since 中,您正在转向基于 TFS2015 update4 的 vNext 构建。强烈建议您使用 Rest API.
您可以通过查询 REST API directly or by using the Team Foundation Server Client NuGet package 从 C# 代码访问它。 样本:
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Build.WebApi;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Uri tfsurl = new Uri("http://xxxx:8080/tfs/CollectionName");
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(tfsurl);
BuildHttpClient bhc = ttpc.GetClient<BuildHttpClient>();
List<Build> builds = bhc.GetBuildsAsync("ProjectName").Result;
foreach (Build bu in builds)
{
Console.WriteLine(bu.BuildNumber);
}
Console.ReadLine();
}
}
}
通过使用上述库中的 Rest API,您可以获得 XAML 和 vNext 构建。