Hi!
When I'm ending the Sonar Analysis the runner and it fails for some reason (the actual error is irrelevant for this question), one would expect that it would return an exit code != 0.
However when I run it in powershell on TeamCity like this:
%system.PATHTO.MSBUILD_SONARQUBE_RUNNER%\MSBuild.SonarQube.Runner.exe end
Write-Host "Lastexitcode: $lastexitcode"
if ($lastexitcode)
{
Write-Error "MsBuild.SonarQube.Runner.exe end failed"
exit(1)
} else {
Write-Output "MsBuild.SonarQube.Runner.exe end as expected"
}
I get this in the build log :
[...Some error that fails the analysis]
[10:58:40][Step 8/8] Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
[10:58:40][Step 8/8] 10:58:40.512 Creating a summary markdown file...
[10:58:40][Step 8/8] 10:58:40.516 Post-processing failed. Exit code: 1
[10:58:40][Step 8/8] Lastexitcode: 0
[10:58:40][Step 8/8] MsBuild.SonarQube.Runner.exe end as expected
[10:58:40][Step 8/8] Process exited with code 0
The line "10:58:40.516 Post-processing failed. Exit code: 1" is written on stderr and the rest on stdout.
Why is $lastexitcode = 0 in this case? How can I detect this error?