modules/teamcityExtensions/MetaRunners/PSCI_SonarqubeAnalysis.xml

<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="PSCI: Sonarqube Analysis">
  <description>Sonarqube analysis</description>
  <settings>
    <parameters>
      <param name="SonarWorkingDir" value="" spec="text validationMode='any' label='Working directory' display='normal'" />
      <param name="SonarProjectKey" value="" spec="text validationMode='not_empty' label='Project key' display='normal'" />
      <param name="SonarProjectName" value="" spec="text validationMode='not_empty' label='Project name' display='normal'" />
      <param name="SonarProjectVersion" value="1.0.0.%build.number%" spec="text validationMode='not_empty' label='Project version' display='normal'" />
      <param name="DotCoverSnapshotPath" value="" spec="text validationMode='any' label='dotCover snapshot file' description='Path to snapshot file generated by dotCover' display='normal'" />
      <param name="DotCoverHtmlReportPath" value="" spec="text validationMode='any' label='dotCover report file' description='Path to dotCover html report that will be generated from snapshot and reused by SonarQube' display='normal'" />
      <param name="SonarAdditionalParameters" value="" spec="text validationMode='any' label='Additional parameters' display='normal'" />
    </parameters>
    <build-runners>
      <runner name="SonarQube" type="jetbrains_powershell">
        <parameters>
          <param name="jetbrains_powershell_bitness" value="x64" />
          <param name="jetbrains_powershell_execution" value="PS1" />
          <param name="jetbrains_powershell_script_code"><![CDATA[try {

if ('%DotCoverSnapshotPath%' -and '%DotCoverHtmlReportPath%') {
  $cmd = (Join-Path %teamcity.dotCover.home% 'dotCover.exe')
  $coverArgs = @('report' , '/Source=%DotCoverSnapshotPath%', '/Output=%DotCoverHtmlReportPath%', '/ReportType=HTML')
  Write-Host $cmd $coverArgs
  & $cmd $coverArgs
}

Write-Host 'Starting SonarQube runner'
$cmd = (Join-Path %env.SONAR_RUNNER_HOME% 'bin\sonar-runner.bat')
$sonarArgs = @('-Dsonar.projectKey=%SonarProjectKey%', '-Dsonar.projectName=%SonarProjectName%', '-Dsonar.projectVersion=%SonarProjectVersion%', '-Dsonar.sources=.')
if ('%DotCoverHtmlReportPath%') {
  $sonarArgs += '-Dsonar.cs.dotcover.reportsPaths=%DotCoverHtmlReportPath%'
}
if ('%SonarAdditionalParameters%') {
  $additionalArgs = '%SonarAdditionalParameters%'
  $sonarArgs += $additionalArgs.Split()
}

Write-Host $cmd $sonarArgs
& $cmd $sonarArgs
exit $lastexitcode
} catch {
  Write-Error $_ -ErrorAction SilentlyContinue
  exit 1
}]]></param>
          <param name="jetbrains_powershell_script_mode" value="CODE" />
          <param name="teamcity.build.workingDir" value="%SonarWorkingDir%" />
          <param name="teamcity.step.mode" value="default" />
        </parameters>
      </runner>
    </build-runners>
    <requirements />
  </settings>
</meta-runner>