构建定义 null [英] BuildDefinition null

查看:17
本文介绍了构建定义 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这段代码来确定特定构建的构建定义详细信息:

I'm using this piece of code to determine the build definition details of a specific build:

TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri);
IBuildServer buildServer = (IBuildServer)tpc.GetService(typeof(IBuildServer));
IBuildDetail bd = buildServer.GetBuild(buildUri);
string a = bd.BuildDefinition.Name;

如果 tfsUri 和 buildUri 指向 TFS2013 服务器和 TFS2013 构建,则代码没问题,但如果我更改为 TFS2015 服务器 + 构建(vNext 构建),则 bd.BuildDefinition 对象变为空.

If the tfsUri and buildUri are pointing to a TFS2013 server and a TFS2013 build then the code is ok but if I change to TFS2015 server + build (vNext build) then the bd.BuildDefinition object becomes null.

如何使用 C# TFS API 获取 vNext 构建的构建详细信息(构建定义)?

How can I get the build details (build definition) of a vNext build using C# TFS API?

推荐答案

我猜您使用的 TFS API 不支持 Build vNext,您可能不得不尝试使用 REST API.

I'm guessing that the TFS API you're using doesn't support Build vNext, you are probably going to have to try using the REST API.

您可以使用它来获取构建定义:

You can use this to get the Build Definitions:

https://{your-project}.visualstudio.com/defaultcollection/taeguk/_apis/build/definitions?api-version=2.0

一旦你有了ID",你就可以使用这个调用:

The once you have the "ID" you can use this call:

https://{your-project}.visualstudio.com/defaultcollection/taeguk/_apis/build/builds?api-version=2.0&definitions={id}

我基于我在 VisualStudio 团队服务 REST API 文档.

这篇关于构建定义 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆