我正在添加构建功能VCS labeling。我可以在标签模式中引用statistics values吗?像
这样的东西build-%system.build.number%-passed-%PassedTestCount%-failed-%FailedTestCount%
如果没有,我可以以某种方式传递统计值来构建参数吗?
更新
出于某种原因,REST API请求
http://teamcity:8111/httpAuth/app/rest/builds/id:$buildId/statistics/
在构建期间不返回大多数值。我不得不使用测试信息请求。这是powershell脚本:
$buildId=%teamcity.build.id%
$userId="%system.teamcity.auth.userId%"
$password="%system.teamcity.auth.password%"
$ApiCredentials_ForHeader = $userId + ":" + $password
$ApiCredentialsBase64 = [System.Convert]::ToBase64String(
[System.Text.Encoding]::UTF8.GetBytes($ApiCredentials_ForHeader))
$ApiCredentialsHeader = @{}
$ApiCredentialsHeader.Add("Authorization", "Basic $ApiCredentialsBase64")
$testsUrl = "http://teamcity:8111/httpAuth/app/rest/testOccurrences?locator=build:(id:$buildId),count:10000"
$response = [xml](Invoke-WebRequest $testsUrl -Headers $ApiCredentialsHeader)
$PassedTestCount = @($response.testOccurrences.testOccurrence | ? { $_.status -eq "SUCCESS" }).count
$FailedTestCount = @($response.testOccurrences.testOccurrence | ? { $_.status -eq "FAILURE" }).count
Write-Host "##teamcity[setParameter name='PassedTestCount' value='$PassedTestCount']"
Write-Host "##teamcity[setParameter name='FailedTestCount' value='$FailedTestCount']"
这解决了我的问题,但没有回答问题。