Reputation: 16178
We give our builds unique build numbers, that include a timestamp and a git commit. Given one of these build numbers (and no other information), I want to find the build configuration that built it.
If I type the build number into the "Search" box in the upper right corner, it works fine, listing the build and noting:
1 build found (matches in build number — 1) in 662ms
How do I access the same information via the REST API? I have checked the API docs, but can't see a call equivalent to the generic "Search" exposed in the UI. Alternatively, I'd like to directly fetch the Build details and/or Build Configuration (http://teamcity:8111/httpAuth/app/rest/buildTypes) via build number alone, but although there is a number:
locator, it can only be used in conjunction with buildType:
(which is exactly the information I'm trying to identify).
Upvotes: 2
Views: 3147
Reputation: 441
Try build requests with build number locator in TeamCity REST API.
We're using API method in PS script to retrieve builds by id like this:
$password = ConvertTo-SecureString -String "$teamcityPassword" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $teamcityUsername, $password
function GetBuild([string] $buildId) {
$url = "$teamcityUrl/httpAuth/app/rest/builds/id:$buildId"
Write-Host "GetBuild:$nl$url"
return Invoke-RestMethod -Uri $url -Credential $credentials -Verbose -WebSession $session
}
So i think you should be able to do similar with "number" locator:
$url = "$teamcityUrl/httpAuth/app/rest/builds/number:$buildNo"
Upvotes: 3