Warren
Warren

Reputation: 581

MSBuild SonarQube Runner v1.0 returns with code 1 after "Generating the FxCop ruleset"

I'm trying out SonarQube using the new MSBuild SonarQube Runner v1.0. If I install a fresh SonarQube server locally, the following command works fine, and I can build my solution directly afterward, call the 'end' command, and have the results published in SonarQube:

MSBuild.SonarQube.Runner.exe begin /key:TestKey /name:TestName /version:1.0.0.0

However, if I run this against an existing SonarQube server that exists on the internal network, it always returns with exit code 1:

15:32:40 Creating config and output folders... 15:32:40 Creating directory: c:\Test\MSBuild.SonarQube.Runner-1.0.itsonar\.sonarqube\conf 15:32:40 Creating directory: c:\Test\MSBuild.SonarQube.Runner-1.0.itsonar\.sonarqube\out 15:32:41 Generating the FxCop ruleset: c:\Test\MSBuild.SonarQube.Runner-1.0.itsonar\.sonarqube\conf\SonarQubeFxCop-cs.ruleset Process returned exit code 1

It seems to download a lot of the dependencies into /.sonarqube, so communication with the server isn't an issue

Things I've tried:

Any help or pointers greatly accepted. I've been stuck on this for 2 days and can't think of anything else to try except continue trawling through source code. Thank you.

Upvotes: 4

Views: 692

Answers (1)

Dinesh Bolkensteyn
Dinesh Bolkensteyn

Reputation: 3011

This is a tricky one! Looking at the code, I see only one path that can yield this output:

  1. It fails while generating the FxCop ruleset for C#, as the VB.NET FxCop ruleset message is not logged - see TeamBuildPreProcessor.cs#L149 and TeamBuildPreProcessor.cs#L185
  2. The GenerateFxCopRuleset() call for C# threw a WebException, leading to the call of Utilities.HandleHostUrlWebException() - which has to return true for the exception to be silently swallowed - see Utilities.cs#L153
  3. The only path returning true without logging any message is if a HttpStatusCode.NotFound was received - see Utilities.cs#L158
  4. The control flow goes back to FetchArgumentsAndRulesets(), which returns false, then goes back to Execute() which returns false as well - see TeamBuildPreProcessor.cs#L106
  5. The MSBuild SonarQube Runner "begin" phase (called "preprocessor" in the code) fails - see Program.cs#L42

So, at some point, some SonarQube web service required for the C# FxCop ruleset generation is return a HTTP 404 error.

Could you monitor your network traffic and listen for the failing HTTP call? [I will keep on updating this answer afterwards]

EDIT: Indeed the error is caused by the quality profile name containing special characters. Such characters are currently badly URL-escaped, which leads to a 404.

I've created the following ticket to fix this issue in the upcoming release: http://jira.sonarsource.com/browse/SONARMSBRU-125

Upvotes: 4

Related Questions