Team City Meta-Runner for TOSCA CI

In TOSCA Distributed Execution, we discussed how to integrate TOSCA Distributed Execution with Team City, which we have two steps for triggering the execution. Since we need to use them for multiple build configuration, so considering to wrap them one step with Team City Meta-Runner.

The Meta-Runner can be extracted from an existing build configuration. In this case, open the build configuration to be extracted, and go to Actions -> Extract Meta-Runner, Enter or adjust values for Project, Name, ID, Description, and then click Extract button, then make changes if required.

Or we could write it manually as long as we have the right XML structure.

Below is the sample Meta-Runner for TOSCA execution, which can be uploaded into your Team City project.
It will take parameters:

  • Test Configuration: Part of TOSCA test configuration file, which insides of node testConfiguration
  • Result file: the junit format result XML file
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="Run TOSCA Test">
  <description>
    Run TOSCA Test
  Sample Usage: 
     Test Configuration:
    <TestEvents>
      <TestEvent>TestEvt</TestEvent>
    </TestEvents>
    Result file: %system.teamcity.buildType.id%_%build.number%_Result.xml
  </description>
  <settings>
    <parameters>
      <param name="Test.Configuration" value="" spec="text display='normal' label='Test Configuration:' validationMode='not_empty'" />
      <param name="Test.ResultFile" value="" spec="text display='normal' label='Result file:' validationMode='not_empty'" />
    </parameters>
    <build-runners>
      <runner name="Generate TOSCA CI Configure File" 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[$tcs=@"
<?xml version="1.0" encoding="utf-16" ?>
<testConfiguration>
%Test.Configuration%
</testConfiguration>

"@
New-Item -Path "c:\Temp" -ItemType "directory" -Force | Out-Null
Out-File -FilePath c:\Temp\%system.teamcity.buildType.id%_%build.number%_TestConfig.xml -InputObject $tcs -Encoding ASCII

Write-Host "##teamcity[message text='Test Configuration file: c:\Temp\%system.teamcity.buildType.id%_%build.number%_TestConfig.xml']"
Write-Host "##teamcity[message text='Test Result file: c:\temp\%Test.ResultFile%']"]]></param>
          <param name="jetbrains_powershell_script_mode" value="CODE" />
          <param name="teamcity.step.mode" value="default" />
        </parameters>
      </runner>
      <runner name="Run Tests" type="simpleRunner">
        <parameters>
          <param name="command.executable" value="%env.TRICENTIS_HOME%\ToscaCommander\ToscaCI\Client\ToscaCIClient.exe" />
          <param name="command.parameters" value="-m distributed -c &quot;c:\Temp\%system.teamcity.buildType.id%_%build.number%_TestConfig.xml&quot; -t junit -r &quot;c:\temp\%Test.ResultFile%&quot; -x True" />
          <param name="teamcity.step.mode" value="default" />
        </parameters>
      </runner>
    </build-runners>
    <requirements />
  </settings>
</meta-runner>