modules/teamcityExtensions/MetaRunners/PSCI_GenerateTestTrendReport.xml

<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="PSCI: Test Trend Report">
  <description>Generates a trend report basing on test results.</description>
  <settings>
    <parameters>
      <param name="trendReport.testName.displayRegex" value="" spec="text validationMode='any' label='Regex for displaying test names' description='If your test name is LongTestPrefix-ActualTestName, you can provide regex LongTestPrefix-(.*) to output only ActualTestName. Multiple regexes can be entered - separate them with newline.' display='normal'" />
      <param name="trendReport.testName.includeRegex" value="" spec="text validationMode='any' label='Include regex' description='Filtering regex - only test names matching this regex will be included' display='normal'" />
      <param name="trendReport.testName.excludeRegex" value="" spec="text validationMode='any' label='Exclude regex' description='Filtering regex - test names matching this regex will be excluded' display='normal'" />
      <param name="trendReport.numberOfLastBuilds" value="30" spec="text validationMode='not_empty' label='Number of last builds' description='Number of builds that will be trended - all earlier builds will be ignored' display='normal'" />
      <param name="trendReport.generateCsv" value="$false" spec="checkbox checkedValue='$true' description='If checked, CSV file will be generated' uncheckedValue='$false' label='Generate output CSV' display='normal'" />
      <param name="trendReport.inputThresholdCsv" value="" spec="text display='normal' description='Path to the CSV with test thresholds - columns TestName,PassedTime,FailedTime. Tests with time &lt;= PassedTime will be marked green, Passed Time &lt; time &lt; FailedTime amber, and time &gt;= FailedTime red.' label='Input threshold CSV'" />
      <param name="trendReport.outputFilePrefix" value="" spec="select display='normal' description='TeamCity tab where the results will be presented' label='Output tab' label_1='Test Trend' data_1='' label_3='Test Trend 2' data_3='2' label_5='Test Trend 3' data_5='3' " />
      <param name="trendReport.tcServerDbConnection.databaseName" value="" spec="text display='hidden'"/>
      <param name="trendReport.tcServerDbConnection.integratedSecurity" value="false" spec="text display='hidden'"/>
      <param name="trendReport.tcServerDbConnection.userId" value="" spec="text display='hidden'"/>
      <param name="trendReport.tcServerDbConnection.password" value="" spec="password display='hidden'" />
    </parameters>
    <build-runners>
      <runner name="Generate Test Trend Reports" type="jetbrains_powershell">
        <parameters>
          <param name="jetbrains_powershell_bitness" value="x86" />
          <param name="jetbrains_powershell_execution" value="PS1" />
          <param name="jetbrains_powershell_script_code"><![CDATA[. c:\PSCI\Boot\PSCI.boot.ps1
try {

$user = '%trendReport.tcServerDbConnection.userId%'
$pass = '%trendReport.tcServerDbConnection.password%'
$integratedSecurity = '%trendReport.tcServerDbConnection.integratedSecurity%' -ieq 'true'
if (!$integratedSecurity -and (!$user -or !$pass)) {
        throw "When integratedSecurity is false, userId and password must not be empty. Please modify this metarunner to enable integratedSecurity or include valid userId and password."
}
$databaseName = '%trendReport.tcServerDbConnection.databaseName%'
$outputFilePrefix = '%trendReport.outputFilePrefix%'

$serverUrl = '%teamcity.serverUrl%' -replace 'http://',''
if ($integratedSecurity) {
    $connectionString = "Server=${serverUrl};Database=${databaseName};Integrated Security=SSPI"
} else {
    $connectionString = "Server=${serverUrl};Database=${databaseName};User Id=${user};Password=${pass}"
}

$includeRegex = @'
%trendReport.testName.includeRegex%
'@
 
$excludeRegex = @'
%trendReport.testName.excludeRegex%
'@

$conversionRegex = Get-TeamcityArrayParameter -Param @'
%trendReport.testName.displayRegex%
'@

$params = @{
    TeamcityBuildId = '%teamcity.build.id%'
    TeamcityDbConnectionString = $connectionString
    OutputDir = 'TestTrend'
    OutputCsvName = "TestTrendReport${outputFilePrefix}.csv"
    OutputHtmlName = "TestTrendReport${outputFilePrefix}.html"
    InputThresholdCsvPath = '%trendReport.inputThresholdCsv%'
    TestNameConversionRegex = $conversionRegex
    TestNameIncludeRegex = $includeRegex
    TestNameExcludeRegex = $excludeRegex
    NumberOfLastBuilds = %trendReport.numberOfLastBuilds%
    GenerateCsvFile = %trendReport.generateCsv%
}

New-TeamcityTrendReport @params

Write-Host "##teamcity[publishArtifacts 'TestTrend => TestTrend']"
} catch {
Write-ErrorRecord
}]]></param>
          <param name="jetbrains_powershell_script_mode" value="CODE" />
          <param name="teamcity.step.mode" value="default" />
        </parameters>
      </runner>
    </build-runners>
    <requirements />
  </settings>
</meta-runner>