Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Teamcity 是否可以将统计值用作生成参数?_Teamcity - Fatal编程技术网

Teamcity 是否可以将统计值用作生成参数?

Teamcity 是否可以将统计值用作生成参数?,teamcity,Teamcity,我正在添加构建功能。我可以在标签模式中引用吗?差不多 build-%system.build.number%-passed-%PassedTestCount%-failed-%FailedTestCount% 如果没有,我可以通过某种方式将统计值传递给构建参数吗 更新 出于某种原因,RESTAPI请求 http://teamcity:8111/httpAuth/app/rest/builds/id:$buildId/statistics/ 在生成期间不返回大多数值。我必须使用测试信息请求。下

我正在添加构建功能。我可以在标签模式中引用吗?差不多

build-%system.build.number%-passed-%PassedTestCount%-failed-%FailedTestCount%
如果没有,我可以通过某种方式将统计值传递给构建参数吗

更新

出于某种原因,RESTAPI请求

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']"

这解决了我的问题,但没有回答问题。

如果其中一个构建步骤是PowerShell(或其他类似)脚本,则可以使用TeamCity API获取统计信息。讨论过