Step one adds hooks to the MSBuild installation on the build agent.
If step 2 fails, how can I remove the hooks from the MSBuild installation so that other builds not involving SonarQube can go ahead?
I cannot find anything in the documentation that describes how to handle a failure during step 2 of the process.
I was expecting to find a ‘clear’ option to go alongside ‘begin’ and ‘end’.
Is it always necessary to run step 3 after successful execution of step 1, even if step 2 fails?
Thanks for the reply, but I don’t understand how enabling concurrent analysis might help. Our build agents (TeamCity) always execute builds serially, never concurrently. I don’t think that TeamCity supports any other execution model. The TeamCity server delegates a build to an agent and will not delegate another build to the same agent until the first build has completed.
I am trying to find out how I go about ensuring that subsequent builds on an agent are not affected by a failure during stage 2 on a previous build, since stage 1 has affected the MSBuild engine.
Apologies! I made a false assumption about what you’re trying to achieve.
I can’t exactly answer your question, but I can tell you that failing builds (on step 2) has never caused an issue with our build pipelines so far as leftover hooks into MSBuild.
Perhaps somebody will come along with a more authoritative answer.
I am not sure how much of a detailed answer you are looking for so I will start with a small one. Each time you run a new begin step we clear the data and redo everything as if it was the first time you run the command.
For example:
First build of the project on your CI
begin step (wipe, download and setup the analysis)
build => fails. As the end step was not called the targets are not cleared so the only impact would be if you re-build without running an analysis.
Second build on your CI
begin step (wipe, download and setup the analysis)
Thank you for the reply. You said “…so the only impact would be if you re-build without running an analysis”
This is exactly the case I am asking about.
I start a build run for Sonar via the ‘begin’ step
I perform the build and it fails.
Currently my ‘end’ step is not called due to the earlier build failure.
I now want to perform a normal (non-Sonar) build on a completely unrelated project on the same build agent.
In order for the normal build to be performed, must I force the ‘end’ step from the previous Sonar build to be executed?
In other words, is it necessary to always perform the ‘end’ step during a Sonar build (regardless of the success or failure of the build itself) in order to ensure that any Sonar hooks within the MSBuild engine are released and that subsequent unrelated builds can proceed?
If so, what are the consequences of running the ‘end’ step if a build has not succeeded? Might I end up with partial results within Sonar?
I really expected there to be a ‘clear’ stage on SonarScanner.MSBuild, so that I could write my builds along these logical lines:
Begin
try {
Build
End
} catch(build failure) {
Clear
}
The target that is dropped in the msbuild import before (by the begin step) is only a kind of bootstrapper that will try to execute the target in the .sonarqube of the project. So even if the end step is not called, all non-sonar projects remain unaffected.