通过 REST 在 TeamCity 上搜索内部版本号 API

Search for build number on TeamCity via REST API

我们为我们的构建提供了唯一的构建编号,其中包括时间戳和 git 提交。给定这些内部版本号之一(以及 没有 其他信息),我想找到构建它的构建配置。

如果我在右上角的 "Search" 框中输入内部版本号,它工作正常,列出内部版本并注意:

1 build found (matches in build number — 1) in 662ms

如何通过 REST API 访问相同的信息?我已经通过内部版本号单独检查了 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),但是虽然有一个 number: 定位器,但它只能与 buildType: 结合使用(这正是我正在尝试的信息识别)。

尝试使用 TeamCity REST API 中的内部版本号定位器构建请求。

我们在 PS 脚本中使用 API 方法通过 id 检索构建,如下所示:

$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
}

所以我认为你应该可以用 "number" 定位器做类似的事情:

$url = "$teamcityUrl/httpAuth/app/rest/builds/number:$buildNo"