问题
I've got Teamcity running build, which has artifact output of *.msi installer, I need to mark successfull and failed tests builds, something like
<filename>_<build_status>.msi
I've set TC to build installer even if some tests are failed, in order to send it our tester. So the thing is to recieve build status from TeamCity environment, without using REST.
回答1:
I realise that you said you didn't want to use REST, but all you need to do is perform a GET request for this URL, substituting your build configuration id. IMO this is the simplest approach (provided the installer build config is a separate build)
/httpAuth/app/rest/builds/buildType:Installer_Build/status
If you need help implementing this then let me know.
IMPLEMENTATION
1) Add a parameter that you want to be set as the output from the GET request
2) Add a PowerShell step and run the code as source - Get Build Status Gist
3) Update the relevant parameters highlighted below to match your settings
Hope this helps
回答2:
This answer I used for an other SO question dose apply for this one too.
It works on TeamCity Enterprise 2017.1.2 (build 46812)
Here you can find my original answer.
[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']"
来源:https://stackoverflow.com/questions/38826604/get-teamcity-build-status