当前运行的TeamCity构建是否可能检测到它是一个;历史建筑;?

当前运行的TeamCity构建是否可能检测到它是一个;历史建筑;?,teamcity,Teamcity,当前运行的TeamCity构建是否可能通过构建参数或api调用检测到它是“历史构建”?我的构建配置以发布NuGet包结束,如果检测到“历史构建”,我想推迟发布。TeamCity server似乎已经检测到此状态,因为正在运行的构建显示为灰色。您可以使用。类似于http://MyTeamCity/app/rest/builds/BUILD_ID 要获取当前生成的BUILD\u ID,请使用%teamcity.BUILD.ID%(teamcity参数) 该调用返回包含给定生成详细信息的XML。如果是

当前运行的TeamCity构建是否可能通过构建参数或api调用检测到它是“历史构建”?我的构建配置以发布NuGet包结束,如果检测到“历史构建”,我想推迟发布。TeamCity server似乎已经检测到此状态,因为正在运行的构建显示为灰色。

您可以使用。类似于
http://MyTeamCity/app/rest/builds/BUILD_ID

要获取当前生成的
BUILD\u ID
,请使用
%teamcity.BUILD.ID%
(teamcity参数)


该调用返回包含给定生成详细信息的XML。如果是历史,则有一个
history=“true”
属性。

我的团队在历史构建和nuget包方面遇到了类似的问题。使用sferencik中的技巧,我能够组合以下PowerShell脚本,该脚本作为所有构建项目的第一步运行(请确保将PowerShell runner选项“Format stderr output as”设置为error)。这将导致生成在检测到历史生成时停止

Write-Host "Checking for history build."

$buildUrl = "%teamcity.serverUrl%/app/rest/builds/%teamcity.build.id%"

Write-Host "URL for build data is $buildUrl"

$wc = New-Object System.Net.WebClient
$cred = New-Object System.Net.NetworkCredential("%system.teamcity.auth.userId%", "%system.teamcity.auth.password%")
$wc.Credentials = $cred

[xml]$buildXml = $wc.DownloadString($buildUrl)

$isHistory = $buildXml.build.GetAttribute("history") -eq "true"

if ($isHistory) {
    Write-Host "##teamcity[buildProblem description='This is a history build and is being abandoned.']"
    Write-Error "Build is history" 
} else {
    Write-Host "Build is not history"
}