Get XAML build info

Just a small followup on Getting latest build in PS as the link is related to vNext build.
But what about the old XAML build, if you still have this?

Here we use the version 1.0 of the REST API and it is quite simple:
First the usual constants:

$tfsServerURL = "HTTP://fabrikam:8080/tfs/defaultcollection"
$TFSProject = "My project"
$BuildDefinition = "MyAwesomeBuild"
$URL = "$($tfsServerURL)/$($TFSProject)"

Then call the REST interface:
(Invoke-RestMethod -Uri ($URL + '/_apis/build/builds?api-version=1.0&definition=' + $BuildDefinition) -Method GET -UseDefaultCredentials).value

If you want to get the latest succeeded build, just add the Status paramter.
(Invoke-RestMethod -Uri ($URL + '/_apis/build/builds?api-version=1.0&definition=' + $BuildDefinition +'&status=Succeeded&$top=1') -Method GET -UseDefaultCredentials).value

Full script:

$tfsServerURL = "HTTP://fabrikam:8080/tfs/defaultcollection"
$TFSProject = "My project"
$BuildDefinition = "MyAwesomeBuild"

$URL = "$($tfsServerURL)/$($TFSProject)"

#Get the specific Build
(Invoke-RestMethod -Uri ($URL + '/_apis/build/builds?api-version=1.0&definition=' + $BuildDefinition +'&status=Succeeded&$top=1') -Method GET -UseDefaultCredentials).value

Documentation is available here: XAML build

Author: KimC

TFS admin and deployment fellow

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s