Getting Build Steps With Visual Studio Team Services .NET API
How to query build steps in Visual Studio Team Services through the .NET API.
By Den Delimarsky in Programming
October 30, 2016
One of the features that I love the most about Visual Studio Team Services is the ability to build my code in the cloud. In my project I have a requirement for dynamic build provisioning, which works well. However, I recently tried to figure out how can I get the list of steps from a build definition, and was hitting a roadblock up until I got some help from Chris Patterson.
I am using the .NET client libraries for accessing the Team Services capabilities (you can easily get the right packages through NuGet).
In my code, I was using the standard call to get the a list of definitions:
|
|
However, for each definition I would only get a BuildDefinitionReference instance:
So what’s missing here? Build steps. Of course, there is the REST API that you can leverage for this scenario, but in this case you’d have to write a custom implementation of the reader (parse out JSON, select the right node, and then transform raw JSON into a list of objects).
Luckily, the right functionality is already built into the SDK, and I wrote a simple helper method to do just what I needed in terms of getting the build steps:
|
|
As long as you have the definition ID (this is not the name, but rather the numeric identifier), you can successfully get a list of steps as now you will bet getting a real BuildDefinition instance that has the Steps property:
Feedback
Have any thoughts? Let me know on Twitter!