Getting the BuildAgent information from a Build

2019-07-10 04:23发布

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

3条回答
唯我独甜
2楼-- · 2019-07-10 04:50

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.

查看更多
Rolldiameter
4楼-- · 2019-07-10 05:09

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));
查看更多
登录 后发表回答