1

I am using SonarQube 5.1 with MSBuild SonarQube Runner for our quality inspection. Currently SCM support is not there although I have already installed TFVC plugin. I get the following log from the analyze process

07:18:22  07:18:22.352 INFO  - Sensor SCM Sensor
07:18:22  07:18:22.352 INFO  - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
07:18:22  07:18:22.352 INFO  - Sensor SCM Sensor (done) | time=0ms

Then I set the following properties in the general "sonar.properites" file loacated in \sonarqube-5.1.2\conf folder (which I might be doing wrong)

sonar.scm.enabled=true
sonar.scm.provider=tfvc
sonar.tfvc.username=myTFSusername
sonar.tfvc.password.secured=myTFSpassword

I guess these properties should be set in the "sonar-project.properties" file and passed at the time of analysis (correct me if I am wrong). But the problem is since I am using MSBuild SonarQube Runner, sonar-project.properties file is not used anymore and the project properties are passed at the analysis time. If that is the case how should I pass them in?

I searched a lot but could not find a proper solution in this manner and I'd be very glad if someone could help.

Thanks in advance.

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
ChatSamee
  • 77
  • 2
  • 7

1 Answers1

1

Additional properties are passed to the MSBuild SonarQube Runner during its begin phase using the following syntax: /d:key=value.

So, you can pass all of them:

MSBuild.SonarQube.Runner begin /k:... /n:... /v:... /d:sonar.scm.enabled=true /d:sonar.scm.provider=tfvc /d:sonar.tfvc.username=... /d:sonar.tfvc.password.secured=....

Auto-detection of the SCM will work if there is a $tf at the "project base dir" level. That directory is computed as the first ancestor path common to all your *.csproj files. You can see its value following the file generated during the end phase: .sonarqube\out\sonar-project.properties. Look for the sonar.projectBaseDir property value near the end of the file. See https://jira.sonarsource.com/browse/SONARMSBRU-8 for details.

Dinesh Bolkensteyn
  • 2,971
  • 1
  • 17
  • 20
  • my initial problem was solved :) but forgive me I didn't get the last part of the answer. the value of `sonar.projectBaseDir` is the solution folder which is also the workspace but now the log says `Unable to TFS annotate the following file which is not in a mapped TFS workspace: ~file name with the absolute path` and this happens for all the files in the solution so that non of them get analyzed. – ChatSamee Aug 26 '15 at 13:22
  • The last part is about auto-detecting that TFS is being used as an SCM, and so to prevent you from having to explicitly set `sonar.scm.provider=tfvc` – Dinesh Bolkensteyn Aug 26 '15 at 13:34
  • Your new problem might relate to https://github.com/SonarCommunity/sonar-scm-tfvc/pull/7 - I will build a snapshot version of the SonarQube SCM TFVC plugin so that you can test if it fixes this problem – Dinesh Bolkensteyn Aug 26 '15 at 13:36
  • You can install this *pre-release* (i.e. **NOT PRODUCTION READY**) version of the SonarQube SCM TFVC plugin to test that pull request and let us know if it helps to solve your issue: https://github.com/SonarCommunity/sonar-scm-tfvc/releases/download/PR7/sonar-scm-tfvc-plugin-2.1-SNAPSHOT.jar – Dinesh Bolkensteyn Aug 26 '15 at 13:49
  • thanks @Dinesh for the help :) with the updated TFVC snapshot TfsAnnotate throws a NullReferenceException :( – ChatSamee Aug 27 '15 at 05:42
  • I tried not passing `sonar.scm.provider=tfvc` and then it doesn't detect TFVC automatically. – ChatSamee Aug 27 '15 at 05:46
  • `Problem signature: Problem Event Name: CLR20r3 Problem Signature 01: sonartfsannotate1440654397653-0 Problem Signature 02: 2.0.0.0 Problem Signature 03: 55ddc35e Problem Signature 04: SonarTfsAnnotate Problem Signature 05: 2.0.0.0 Problem Signature 06: 55ddc35e Problem Signature 07: 1d Problem Signature 08: d1 Problem Signature 09: System.NullReferenceException OS Version: 6.1.7601.2.1.0.16.7 Locale ID: 1044` sorry about the formatting – ChatSamee Aug 27 '15 at 05:50
  • Ok, could you try to invoke SonarTfsAnnotate.exe manually? Enter on the first line the username (or empty), the password on the 2nd line (or empty), and then absolute paths to files to be annotated? Perhaps that will at least produce a better stack trace. – Dinesh Bolkensteyn Aug 27 '15 at 14:16
  • You'll find the SonarTfsAnnotate.exe file in the sonar-scm-tfvc-plugin-2.1-SNAPSHOT.jar archive, rename the .jar into a .zip – Dinesh Bolkensteyn Aug 27 '15 at 14:20
  • `Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at SonarSource.TfsAnnotate.Program.Main(String[] args)` This is the only stack trace I which I was able to capture. :( I tried with visual studio debugger also, but couldn't find more detail than this – ChatSamee Aug 31 '15 at 03:59
  • So it seems that PR as it is doesn't solve your problem, at least yet - I'd suggest to continue the discussion on GitHub as it will be easier to track comments & collaborate with the development team there. – Dinesh Bolkensteyn Sep 07 '15 at 09:50
  • I removed the cache checked in and tried, It worked perfectly :) thanks @Dinesh – ChatSamee Sep 09 '15 at 03:15