Back to Top

Get Build Statuses By Build Number Through the SOAP API

There are times when a third-party tool may be interested in retrieving the status of a build in BuildMaster, generally to be consumed by a custom tool that you have written. One of the ways to achieve this is to access the BuildMaster SOAP API. The SOAP API is recommended for users who are familiar with .NET development, as the returned objects are in ADO.NET format. For other methods of consumption, the JSON api is recommended.


This tutorial was originally designed for BuildMaster v4. The screenshots and concepts may be a little out of date. There is an updated tutorial for BuildMaster v5 with a simpler method to retrieve the data.

Step 1: Enable the API

To enable the API, you must set an API key within BuildMaster. Simply navigate to "Admin" > "All Settings" and set the "ApiKey" setting to whatever value you'd like.

Step 2: Connect to the SOAP API in Visual Studio

To connect to the SOAP API and generate the appropriate .NET classes, create a new project in Visual Studio and choose "Add Service Reference" for the project (or "Add Web Reference" directly in pre-2010 instances of Visual Studio), then "Advanced…", then under Compatibility "Add Web Reference…".

Once you fill in the path to the SOAP API (http://buildmaster-server/api/soap) and click the
"go" button you should see:

connecting to the SOAP API in Visual Studio

Once you select "Add Reference", Visual Studio will generate the classes used to connect to API.

Step 3: Get the Build Details

Once the classes have been generated, to get details for a specific build use the Builds_GetBuild method specifying the API key, application, release, and build numbers:

        var service = new buildmaster.ApiService();
        service.UseDefaultCredentials = true;
        DataRow build = service.Builds_GetBuild(
            "422f53c2-505e-4669-8b30-2915d97d572c",
            16,
            "145",
            "3"
        ).Rows[0];
 
        Console.Write(build["BuildStatus_Name"]);
    

This will display the status of the build to the console window. To get the full list of column names in a strongly-typed format, install the BuildMaster SDK from NuGet and you will have access to the Inedo.BuildMaster.Data.TableDefs class, which makes the specific data you're looking for easier to find.

For example, printing out the current environment of the build:

        Console.Write(string.Format(
            "{0} Build {1}.{2} is currently in {3}",
            build[TableDefs.Builds_Extended.Application_Name],
            build[TableDefs.Builds_Extended.Release_Number],
            build[TableDefs.Builds_Extended.Build_Number],
            build[TableDefs.Builds_Extended.Current_Environment_Name]
        ));