0

We've integrated TeamCity with the SonarQube as a part of our build process. When ever I run the sonar job in TeamCity, after the build is complete I see the build version in SonarQube but the code(LOC-Lines of code) is not being pushed.

We are using TeamCity 9.1.3 Enterprise version and SonarQube 4.5.7. Please see the attachments for reference.

Analysis configuration in TeamCity

Resulting metrics

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199

1 Answers1

1

Your analysis configuration screenshot shows that you've pointed SonarQube Scanner to a .sln file as the location of your project's source code. Since there's no actual code in the .sln itself... that would be your problem. The analysis is running and "pushing" results into SonarQube, but those results are empty because no code is found during the analysis.

Then there's the fact that you're trying to analyze a .NET project with the SonarQube Scanner. That used to be the recommended way of doing it, but it required a lot of configuration on your part and it was nearly impossible to get all the t's crossed and i's dotted. So SonarQube Scanner for MSBuild was introduced to relieve you of that burden.

To use SonarQube Scanner for MSBuild, you need to run 3 separate commands, and I suspect using a command line approach is going to be easiest (but I've never used TeamCity, so there could be some feature I'm unaware of to handle SonarQube Scanner for MSBuild analysis).

Here's a link to the docs, but in short what you need to do is

  1. make sure the SonarQube Scanner for MSBuild is available to your analysis job
  2. run MSBuild.SonarQube.Runner.exe begin /k:"sonarqube_project_key" /n:"sonarqube_project_name" /v:"sonarqube_project_version"
  3. do your normal build
  4. run MSBuild.SonarQube.Runner.exe end
G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76