Back to Top

Get a Complete Build Log by Build Number Through the JSON API

The JSON API is the recommended method for technologies other than .NET to interface with BuildMaster.


This tutorial was originally designed for BuildMaster v4. The screenshots and concepts may be a little out of date. An updated tutorial for BuildMaster v5 is coming soon.

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 JSON API

The JSON API is accessible at the URL: http://buildmaster-server/api/json

Visiting the page will describe the list of methods that can be called. The arguments can be passed in one of two ways, either via a GET request with the arguments specified in the query string:

http://buildmaster-server/api/json/Method_Name?API_Key=yourKey&Argument_1=value1&Argument_2=value2

Or they may be provided via HTTP POST by supplying a JSON object representing the arguments in the request body.

As an example, to get the build execution log by build number, we will make an HTTP POST request to the Builds_GetExecutionLog method (which according to the overview, accepts an Execution_Id. Since we don't know which executions are associated with this build yet, we'll have to get the list of executions for a specific build (in this example, Build 2 of Release 1.1)  with the Builds_GetExecutions method by making a request to http://buildmaster.localhost/api/json/Builds_GetExecutions.

The following method call using jQuery's getJSON will return all the executions for Build 2 of Release 1.1 in the application with the ID of 3. Each value of the property "Execution_Id" will give us a series of Execution IDs to iterate in the Builds_GetExecutionLog call:

    $.getJSON(
	    'http://buildmaster.localhost/api/json/Builds_GetExecutions',
	    {
		    'API_Key': '422f53c2-505e-4669-8b30-29d5197d572c',
		    'Application_Id': 3,
		    'Release_Number': '1.1',
		    'Build_Number': '2'
	    },
	    function(data) {
		    for(var i = 0; i < data.length; i++) {
			    console.log(data[i].Execution_Id);
		    }
	    }
    );

Running this in a browser would output the executions IDs to the browser console. In my example, I will see 2 execution IDs because I created a build of my application, then promoted it to its next environment. Now that I have the IDs, if I replace the console.log command with a second query to Builds_GetExecutionLog for each execution ID, I will receive the logs for each execution as JavaScript object. For brevity, I will call the API method once as an example with an ID returned from the previous call (1051):

    $.getJSON(
	    'http://buildmaster.localhost/api/json/Builds_GetExecutionLog',
	    {
		    'API_Key': '422f53c2-505e-4669-8b30-29d5197d572c',
		    'Execution_Id': 1051
	    },
	    function(data) {
		    console.log(data);
	    }
    );

The object returned in the success function will be an array of all the log messages for the chosen build.