从构建中获取 BuildAgent 信息

发布于 2024-10-31 09:32:30 字数 375 浏览 1 评论 0原文

我有一个 IBuildDetail 变量,其中包含我需要的构建信息。

好的,但是当我检查属性 BuildAgent 时,它显示以下内容: build.BuildAgent' 引发了类型为 'System.NotImplementedException 的异常

然后我尝试检查 build.BuildController.Agents,很高兴我找到了 BuildAgent,但有 7 个构建代理在这个集合中。我只需要与我的构建相关的构建代理,而不需要来自该控制器的所有构建代理。

有人知道如何获取该信息吗? (使用 IBuildDetail 变量选择构建代理名称或计算机名称)

->我正在使用 TFS2010 api,我需要知道每个构建的代理是什么

I have a IBuildDetail variable with the build information I need.

Okay, but when I check the property BuildAgent it's showing this: build.BuildAgent' threw an exception of type 'System.NotImplementedException

Then I tryed to check build.BuildController.Agents, it's nice I found the BuildAgent, but there are 7 build agents in this collection. I need only the build agent related to my build, not all build agents from that controller.

Anyone knows how to get that information? (Select a build agent name or machine name using an IBuildDetail variable)

-> I'm using TFS2010 api and I need to what is the agent for each build

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

终止放荡 2024-11-07 09:32:30

正如 Duat 所说。
为了回答这个问题,我有机会探索这一点。
以下内容适用于给定的 IBuildDetail buildDetail &访问 IBuildServer buildService

IBuildInformation buildInformation = buildDetail.Information;
IBuildInformationNode[] buildInformationNodes = buildInformation.Nodes;
string agentUri = buildInformationNodes[0].Children.Nodes[3].Fields["ReservedAgentUri"];
IBuildAgent buildAgent = buildService.GetBuildAgent(new Uri(agentUri));

It's like Duat says.
In order to answer this question, I had the chance to explore this.
The following worked for a given IBuildDetail buildDetail & access to a IBuildServer buildService:

IBuildInformation buildInformation = buildDetail.Information;
IBuildInformationNode[] buildInformationNodes = buildInformation.Nodes;
string agentUri = buildInformationNodes[0].Children.Nodes[3].Fields["ReservedAgentUri"];
IBuildAgent buildAgent = buildService.GetBuildAgent(new Uri(agentUri));
南烟 2024-11-07 09:32:30

在 Run On Agent 范围内,您需要有一个 GetBuildAgent 活动,该活动将 BuildAgent 详细信息分配给 IBuildAgent 类型的变量。

然后,您可以访问该变量的属性,以访问有关构建代理的数据:http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.client.ibuildagent.aspx

注意:默认构建工作流程已执行此操作。

Inside the Run On Agent scope you need to have a GetBuildAgent activity that assigns the BuildAgent details to a variable of type IBuildAgent.

You can then access the properties of that variable to get access to data about the Build Agent: http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.client.ibuildagent.aspx

Note: The default build workflow does this already.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文