Get TeamCity Build Status

I have started the Teamcity build, which has the output of the * .msi installer artifact, I need to note the successful and unsuccessful builds of the tests, something like

<filename>_<build_status>.msi

I installed TC to install the installer, even if some tests failed to send it to our tester. So, you need to get build status from TeamCity without using REST.

0
source share
2 answers

, , REST, , , GET URL-, . IMO ( , )

/httpAuth/app/rest/builds/buildType:Installer_Build/status

, .

1) , GET

2) PowerShell -

3) , ,

enter image description here

,

+2

, SO, .

TeamCity Enterprise 2017.1.2 ( 46812)

.

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

$buildId = "%teamcity.build.id%"
function TeamCityBuildStatus
{
    param
    (
        [string] $ServerUrl,
        [string] $UserName,
        [string] $Password,
        [string] $BuildId
    )

        $client = New-Object System.Net.WebClient

        $pair = "$($UserName):$Password"
        $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
        $client.Headers.Add("Authorization", "Basic $encodedCreds")

        $url = "https://$ServerUrl/httpAuth/app/rest/builds/$buildId/status"

        $status = $client.DownloadString($url)

        return $status -eq "SUCCESS"
}

$status = TeamCityBuildStatus -ServerUrl $teamcityUrl -UserName $teamcityUser -Password $teamcityPass -BuildId $buildId
Write-Host "##teamcity[setParameter name='Status' value='$status']"
0

Source: https://habr.com/ru/post/1680126/


All Articles