Search code examples
gitmsbuildsonarqubeteamcitysonarqube-scan

Sonarqube - SCM provider autodetection and PR decoration failed for analysis in directory with .git


Must-share information:

  • SonarQube 9.1

  • TeamCity 2020.2.3

  • Teamcity Tool: SonarScanner for MSBuild 4.8.12008

  • Sonar analysis command run inside a Dockerfile

  • Goal: Getting SCM autodetection and PR decoration to work so Sonar can post quality gate report and decoration to Github Repo

I've spent the whole day trying to get this to work with no luck. Tried multiple things already suggested in many threads but cannot solve this. Hoping someone here can take a look and save me :)

Upon doing a Sonar Analysis scan for a project, I’ve got two warnings in SonarQube:

  • “SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.”
  • Decoration failed. No revision information available

These are the sonar logs for the analysis:

      Step 34/41 : RUN if [ -n "$SONAR_LOGIN" ]; then dotnet-sonarscanner end /d:sonar.login=$SONAR_LOGIN; fi
      Docker event: {"status":"destroy","id":"fc409ea02296ddf0ee9fc6471dab927268f1ec9eea3b1771c825ce575d332a23","from":"sha256:39c23cd9879fb2871c00d0bf3873478919f5d57064cfee598729578528386a93","Type":"container","Action":"destroy","Actor":{"ID":"fc409ea02296ddf0ee9fc6471dab927268f1ec9eea3b1771c825ce575d332a23","Attributes":{"image":"sha256:39c23cd9879fb2871c00d0bf3873478919f5d57064cfee598729578528386a93","name":"eager_jackson"}},"scope":"local","time":1636400846,"timeNano":1636400846688421496}
       ---> Running in 409fa2e67ae7
      Docker event: {"status":"create","id":"409fa2e67ae70fedbbdb8ceac00acda59e06a646456f035d12c60d981a301987","from":"sha256:51fdd0e76ab4832a12298b0e5f830b0e659a5d554bb8d26fae75690d44d8c4b4","Type":"container","Action":"create","Actor":{"ID":"409fa2e67ae70fedbbdb8ceac00acda59e06a646456f035d12c60d981a301987","Attributes":{"image":"sha256:51fdd0e76ab4832a12298b0e5f830b0e659a5d554bb8d26fae75690d44d8c4b4","name":"happy_cori"}},"scope":"local","time":1636400846,"timeNano":1636400846769300895}
      Docker event: {"status":"attach","id":"409fa2e67ae70fedbbdb8ceac00acda59e06a646456f035d12c60d981a301987","from":"sha256:51fdd0e76ab4832a12298b0e5f830b0e659a5d554bb8d26fae75690d44d8c4b4","Type":"container","Action":"attach","Actor":{"ID":"409fa2e67ae70fedbbdb8ceac00acda59e06a646456f035d12c60d981a301987","Attributes":{"image":"sha256:51fdd0e76ab4832a12298b0e5f830b0e659a5d554bb8d26fae75690d44d8c4b4","name":"happy_cori"}},"scope":"local","time":1636400846,"timeNano":1636400846769512782}
      Docker event: {"status":"start","id":"409fa2e67ae70fedbbdb8ceac00acda59e06a646456f035d12c60d981a301987","from":"sha256:51fdd0e76ab4832a12298b0e5f830b0e659a5d554bb8d26fae75690d44d8c4b4","Type":"container","Action":"start","Actor":{"ID":"409fa2e67ae70fedbbdb8ceac00acda59e06a646456f035d12c60d981a301987","Attributes":{"image":"sha256:51fdd0e76ab4832a12298b0e5f830b0e659a5d554bb8d26fae75690d44d8c4b4","name":"happy_cori"}},"scope":"local","time":1636400847,"timeNano":1636400847095143532}
      SonarScanner for MSBuild 5.3.2
      Using the .NET Core version of the Scanner for MSBuild
      Post-processing started.
      Calling the SonarScanner CLI...
      Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.3.2/dotnet-sonarscanner/5.3.2/tools/netcoreapp3.0/any/sonar-scanner-4.6.2.2472/conf/sonar-scanner.properties
      Project root configuration file: /source/.sonarqube/out/sonar-project.properties
      SonarScanner 4.6.2.2472
      Java 11.0.13 Oracle Corporation (64-bit)
      Linux 4.15.0-156-generic amd64
      User cache: /root/.sonar/cache
      Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.3.2/dotnet-sonarscanner/5.3.2/tools/netcoreapp3.0/any/sonar-scanner-4.6.2.2472/conf/sonar-scanner.properties
      Project root configuration file: /source/.sonarqube/out/sonar-project.properties
      Analyzing on SonarQube server 9.1.0
      User cache: /root/.sonar/cache
      Load/download plugins
      Load plugins index
      Load plugins index (done) | time=48ms
      Load/download plugins (done) | time=5012ms
      Loaded core extensions: developer-scanner
      Process project properties
      Process project properties (done) | time=26ms
      Execute project builders
      Execute project builders (done) | time=45ms
      Project key: plentyofcode_Matching
      Base dir: /source
      Working dir: /source/.sonarqube/out/.sonar
      Load project settings for component key: 'plentyofcode_Matching' (done) | time=59ms
      Load project branches (done) | time=48ms
      Load project pull requests (done) | time=62ms
      Load branch configuration
      Found manual configuration of branch/PR analysis. Skipping automatic configuration.
      Load branch configuration (done) | time=3ms
      Load quality profiles (done) | time=119ms
      Load active rules (done) | time=3085ms
      WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.
      Pull request 3 for merge into release/2.3.0 from PR1-Test
      Indexing files...
      Project configuration:
        Excluded sources: *.generated.*, *Generat*, *generated*, AssemblyInfo.cs, **/AssemblyInfo.cs, **/AssemblyVersionInfo.cs, api.html, **/Startup.cs, **/Program.cs, **/*.sql
        Excluded tests: **/*.json
      Indexing files of module 'Matching.Tests'
        Base dir: /source/tests/Matching.Tests
        Test paths: Controllers/ApiControllerTests.cs, Logic/Handlers/Events/Accoun...
        Excluded sources: *.generated.*, *Generat*, *generated*, AssemblyInfo.cs, **/AssemblyInfo.cs, **/AssemblyVersionInfo.cs, api.html, **/Startup.cs, **/Program.cs, **/*.sql
        Excluded tests: **/*.json
      Load project repositories
      Load project repositories (done) | time=36ms
      Indexing files of module 'Matching.Benchmarks'
        Base dir: /source/tests/Matching.Benchmarks
        Source paths: Handlers/Events/AccountActivatedHandlerBenchmarks.cs, Handler...
        Excluded sources: *.generated.*, *Generat*, *generated*, AssemblyInfo.cs, **/AssemblyInfo.cs, **/AssemblyVersionInfo.cs, api.html, **/Startup.cs, **/Program.cs, **/*.sql
        Excluded tests: **/*.json
      Indexing files of module 'Matching'
        Base dir: /source/src/Matching
        Source paths: Controllers/ApiController.cs, Middleware/ExceptionMiddleware....
        Excluded sources: *.generated.*, *Generat*, *generated*, AssemblyInfo.cs, **/AssemblyInfo.cs, **/AssemblyVersionInfo.cs, api.html, **/Startup.cs, **/Program.cs, **/*.sql
        Excluded tests: **/*.json
      Indexing files of module 'Matching.Migration'
        Base dir: /source/src/Matching.Migration
        Source paths: Extensions/CustomTableJournal.cs, Extensions/DbUpExtensions.c...
        Excluded sources: *.generated.*, *Generat*, *generated*, AssemblyInfo.cs, **/AssemblyInfo.cs, **/AssemblyVersionInfo.cs, api.html, **/Startup.cs, **/Program.cs, **/*.sql
        Excluded tests: **/*.json
      Indexing files of module 'Matching.IntegrationTests'
        Base dir: /source/tests/Matching.IntegrationTests
        Test paths: Http/BroadcastViewerTests.cs, Http/FirstLookHandlerTests.cs, Ht...
        Excluded sources: *.generated.*, *Generat*, *generated*, AssemblyInfo.cs, **/AssemblyInfo.cs, **/AssemblyVersionInfo.cs, api.html, **/Startup.cs, **/Program.cs, **/*.sql
        Excluded tests: **/*.json
      Indexing files of module 'MatchingGH'
        Base dir: /source
        Excluded sources: *.generated.*, *Generat*, *generated*, AssemblyInfo.cs, **/AssemblyInfo.cs, **/AssemblyVersionInfo.cs, api.html, **/Startup.cs, **/Program.cs, **/*.sql
        Excluded tests: **/*.json
      340 files indexed
      104 files ignored because of inclusion/exclusion patterns
      Quality profile for cs: Sonar way
      ------------- Run sensors on module Matching
      Load metrics repository
      Load metrics repository (done) | time=38ms
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=1ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp8
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=5ms
      Sensor C# Properties [csharp] (done) | time=1ms
      Sensor JavaXmlSensor [java] (done) | time=0ms
      Sensor HTML [web]
      Sensor HTML [web] (done) | time=2ms
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
      Sensor ThymeLeaf template sensor [securityjavafrontend]
      Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms
      Sensor Serverless configuration file sensor [securityjsfrontend]
      0 Serverless function entries were found in the project
      0 Serverless function handlers were kept as entrypoints
      Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=53ms
      Sensor AWS SAM template file sensor [securityjsfrontend]
      Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=1ms
      ------------- Run sensors on module Matching.Benchmarks
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=0ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp8
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=2ms
      Sensor C# Properties [csharp]
      Sensor C# Properties [csharp] (done) | time=0ms
      Sensor JavaXmlSensor [java]
      Sensor JavaXmlSensor [java] (done) | time=1ms
      Sensor HTML [web]
      Sensor HTML [web] (done) | time=0ms
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
      Sensor ThymeLeaf template sensor [securityjavafrontend]
      Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
      Sensor Serverless configuration file sensor [securityjsfrontend]
      0 Serverless function entries were found in the project
      0 Serverless function handlers were kept as entrypoints
      Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=2ms
      Sensor AWS SAM template file sensor [securityjsfrontend]
      Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=1ms
      ------------- Run sensors on module Matching.Logic
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=0ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp8
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=1ms
      Sensor VB.NET Properties [vbnet] (done) | time=0ms
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
      Sensor ThymeLeaf template sensor [securityjavafrontend]
      Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
      Sensor Serverless configuration file sensor [securityjsfrontend]
      0 Serverless function entries were found in the project
      0 Serverless function handlers were kept as entrypoints
      Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=1ms
      Sensor AWS SAM template file sensor [securityjsfrontend]
      Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=1ms
      ------------- Run sensors on module Matching.Migration
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=1ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp8
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=0ms
      ------------- Run sensors on module Matching.IntegrationTests
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=1ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp8
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=1ms
      Sensor C# Properties [csharp]
      Sensor C# Properties [csharp] (done) | time=0ms
      Sensor JavaXmlSensor [java]
      Sensor JavaXmlSensor [java] (done) | time=1ms
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
      Sensor ThymeLeaf template sensor [securityjavafrontend]
      Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms
      Sensor Serverless configuration file sensor [securityjsfrontend]
      0 Serverless function entries were found in the project
      0 Serverless function handlers were kept as entrypoints
      Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=1ms
      Sensor AWS SAM template file sensor [securityjsfrontend]
      Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=0ms
      ------------- Run sensors on module ImageBarsSync.Cli
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=0ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp7_1
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=1ms
      Sensor C# Properties [csharp]
      Sensor C# Properties [csharp] (done) | time=1ms
      Sensor JavaXmlSensor [java]
      Sensor JavaXmlSensor [java] (done) | time=0ms
      Sensor HTML [web]
      Sensor HTML [web] (done) | time=1ms
      Sensor VB.NET Project Type Information [vbnet]
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
      Sensor ThymeLeaf template sensor [securityjavafrontend]
      Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms
      Sensor Serverless configuration file sensor [securityjsfrontend]
      0 Serverless function entries were found in the project
      0 Serverless function handlers were kept as entrypoints
      Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=1ms
      Sensor AWS SAM template file sensor [securityjsfrontend]
      Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=1ms
      ------------- Run sensors on module MeetMe.Migration
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=0ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp8
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=1ms
      Sensor C# Properties [csharp]
      Sensor C# Properties [csharp] (done) | time=1ms
      Sensor JavaXmlSensor [java]
      Sensor JavaXmlSensor [java] (done) | time=0ms
      Sensor HTML [web]
      Sensor HTML [web] (done) | time=0ms
      Sensor VB.NET Project Type Information [vbnet]
      Sensor VB.NET Project Type Information [vbnet] (done) | time=0ms
      Sensor VB.NET Analysis Log [vbnet]
      Sensor VB.NET Analysis Log [vbnet] (done) | time=1ms
      Sensor VB.NET Properties [vbnet]
      Sensor VB.NET Properties [vbnet] (done) | time=0ms
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
      Sensor ThymeLeaf template sensor [securityjavafrontend]
      Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
      Sensor Serverless configuration file sensor [securityjsfrontend]
      0 Serverless function entries were found in the project
      0 Serverless function handlers were kept as entrypoints
      Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=1ms
      Sensor AWS SAM template file sensor [securityjsfrontend]
      Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=0ms
      ------------- Run sensors on module Matching.Tests
      Sensor C# Project Type Information [csharp]
      Sensor C# Project Type Information [csharp] (done) | time=0ms
      Sensor C# Analysis Log [csharp]
      Roslyn version: 3.7.0.0
      Language version: CSharp8
      Concurrent execution: disabled
      Sensor C# Analysis Log [csharp] (done) | time=1ms
      Sensor C# Properties [csharp]
      Sensor C# Properties [csharp] (done) | time=1ms
      Sensor JavaXmlSensor [java]
      Sensor JavaXmlSensor [java] (done) | time=1ms
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      ------------- Run sensors on module MatchingGH
      Sensor JaCoCo XML Report Importer [jacoco]
      'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
      No report imported, no coverage information will be imported by JaCoCo XML Report Importer
      Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
      Sensor ThymeLeaf template sensor [securityjavafrontend]
      Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
      Sensor Serverless configuration file sensor [securityjsfrontend]
      0 Serverless function entries were found in the project
      0 Serverless function handlers were kept as entrypoints
      Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=1ms
      Sensor AWS SAM template file sensor [securityjsfrontend]
      Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=1ms
      Sensor JavaSecuritySensor [security]
      Reading type hierarchy from: /source/.sonarqube/out/.sonar/ucfg2/java
      Read 0 type definitions
      Reading UCFGs from: /source/.sonarqube/out/.sonar/ucfg2/java
      No UCFGs have been included for analysis.
      Sensor JavaSecuritySensor [security] (done) | time=3ms
      Sensor CSharpSecuritySensor [security]
      Reading type hierarchy from: /source/.sonarqube/out/ucfg_cs2
      Read 176 type definitions
      Reading UCFGs from: /source/.sonarqube/out/ucfg_cs2
      Analyzing 1888 ucfgs to detect vulnerabilities.
      All rules entrypoints : 0
      Retained UCFGs : 0
      Taint analysis starting. Entrypoints: 0
      Taint analysis: done.
      Sensor CSharpSecuritySensor [security] (done) | time=2039ms
      Sensor PhpSecuritySensor [security]
      Reading type hierarchy from: /source/.sonarqube/out/.sonar/ucfg2/php
      Read 0 type definitions
      Reading UCFGs from: /source/.sonarqube/out/.sonar/ucfg2/php
      No UCFGs have been included for analysis.
      Sensor PhpSecuritySensor [security] (done) | time=0ms
      Sensor PythonSecuritySensor [security]
      Reading type hierarchy from: /source/.sonarqube/out/.sonar/ucfg2/python
      Read 0 type definitions
      Reading UCFGs from: /source/.sonarqube/out/.sonar/ucfg2/python
      No UCFGs have been included for analysis.
      Sensor PythonSecuritySensor [security] (done) | time=1ms
      Sensor JsSecuritySensor [security]
      Reading type hierarchy from: /source/.sonarqube/out/.sonar/ucfg2/js
      Read 0 type definitions
      Reading UCFGs from: /source/.sonarqube/out/.sonar/ucfg2/js
      19:47:42.897046 Building Runtime Type propagation graph
      19:47:42.897208 Running Tarjan on 0 nodes
      19:47:42.897318 Tarjan found 0 components
      19:47:42.897434 Variable type analysis: done
      19:47:42.897484 Building Runtime Type propagation graph
      19:47:42.897618 Running Tarjan on 0 nodes
      19:47:42.897752 Tarjan found 0 components
      19:47:42.897839 Variable type analysis: done
      Analyzing 2 ucfgs to detect vulnerabilities.
      Taint analysis starting. Entrypoints: 3
      Running symbolic analysis for 'JS'
      Taint analysis: done.
      Sensor JsSecuritySensor [security] (done) | time=205ms
      ------------- Run sensors on project
      Sensor C# [csharp]
      Importing results from 6 proto files in '/source/.sonarqube/out/5/output-cs'
      Importing results from 6 proto files in '/source/.sonarqube/out/6/output-cs'
      Importing 8 Roslyn reports
      Found 8 MSBuild C# projects: 6 MAIN projects. 2 TEST projects.
      Sensor C# [csharp] (done) | time=528ms
      Sensor C# Tests Coverage Report Import [csharp]
      Parsing the OpenCover report /artifacts/reports/coverage.opencover.xml
      Adding this code coverage report to the cache for later reuse: /artifacts/reports/coverage.opencover.xml
      Coverage Report Statistics: 118 files, 118 main files, 118 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.
      Sensor C# Tests Coverage Report Import [csharp] (done) | time=134ms
      Sensor Zero Coverage Sensor
      Sensor Zero Coverage Sensor (done) | time=7ms
      SCM Publisher No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
      CPD Executor 42 files had no CPD blocks
      CPD Executor Calculating CPD for 145 files
      CPD Executor CPD calculation finished (done) | time=46ms
      Analysis report generated in 113ms, dir size=1.9 MB
      Analysis report compressed in 339ms, zip size=809.5 kB
      Analysis report uploaded in 140ms
      ------------- Check Quality Gate status
      Waiting for the analysis report to be processed (max 300s)
      ------------------------------------------------------------------------
      EXECUTION FAILURE
      ------------------------------------------------------------------------
      Total time: 42.217s
      Final Memory: 33M/127M
      ------------------------------------------------------------------------
       [91mERROR: Error during SonarScanner execution
       [0m [91mERROR: QUALITY GATE STATUS: FAILED - View details on http://sonar.integration.pof.local:9000/dashboard?id=plentyofcode_Matching&pullRequest=3
       [0m [91mERROR: 
       [0m [91mThe SonarScanner did not complete successfully

I'm aware if SCM is not working it means analysis isn’t seeing the .git files in the project directory. But there is! This is the directory where TeamCity checks out the code (I'm doing agent side checkout) and you can see the .git directory there:

To prove this I explicitly added the following arguments to the Sonar analysis command as suggested in some threads: /d:sonar.projectBaseDir=%teamcity.build.checkoutDir% <- (build checkout directory above that has .git dir) /d:sonar.scm.provider=git

After running, it gives this error: ERROR: Error during SonarScanner execution ERROR: Not inside a Git work tree: /home/tcservice/buildAgent/work/59055310711a86a1

but as you can see above, this directory is inside a work tree! Full logs for this analysis here:

      Step 35/42 : RUN if [ -n "$SONAR_LOGIN" ]; then dotnet-sonarscanner end /d:sonar.login=$SONAR_LOGIN; fi
      Docker event: {"status":"destroy","id":"869a9a6b70abb09b6fd78dfd3b11e5279ab8a8c2c0cc572cc3aaa84f435cd502","from":"sha256:549533784db7d1bc8af27ae12552b99737b7191d3b75c5f0f101986f468f0f51","Type":"container","Action":"destroy","Actor":{"ID":"869a9a6b70abb09b6fd78dfd3b11e5279ab8a8c2c0cc572cc3aaa84f435cd502","Attributes":{"image":"sha256:549533784db7d1bc8af27ae12552b99737b7191d3b75c5f0f101986f468f0f51","name":"silly_antonelli"}},"scope":"local","time":1636413669,"timeNano":1636413669164488868}
       ---> Running in fd2cd7633f9e
      Docker event: {"status":"create","id":"fd2cd7633f9e9eb6f2df062cfb6587d6802a118febdcf300a6ef7fcfc25b07be","from":"sha256:ea3f0ec9718aa5d29021b755b489ffb7ab5cde1fc26d8805ac9ede84ef900740","Type":"container","Action":"create","Actor":{"ID":"fd2cd7633f9e9eb6f2df062cfb6587d6802a118febdcf300a6ef7fcfc25b07be","Attributes":{"image":"sha256:ea3f0ec9718aa5d29021b755b489ffb7ab5cde1fc26d8805ac9ede84ef900740","name":"wizardly_elbakyan"}},"scope":"local","time":1636413669,"timeNano":1636413669232030425}
      Docker event: {"status":"attach","id":"fd2cd7633f9e9eb6f2df062cfb6587d6802a118febdcf300a6ef7fcfc25b07be","from":"sha256:ea3f0ec9718aa5d29021b755b489ffb7ab5cde1fc26d8805ac9ede84ef900740","Type":"container","Action":"attach","Actor":{"ID":"fd2cd7633f9e9eb6f2df062cfb6587d6802a118febdcf300a6ef7fcfc25b07be","Attributes":{"image":"sha256:ea3f0ec9718aa5d29021b755b489ffb7ab5cde1fc26d8805ac9ede84ef900740","name":"wizardly_elbakyan"}},"scope":"local","time":1636413669,"timeNano":1636413669232237774}
      Docker event: {"status":"start","id":"fd2cd7633f9e9eb6f2df062cfb6587d6802a118febdcf300a6ef7fcfc25b07be","from":"sha256:ea3f0ec9718aa5d29021b755b489ffb7ab5cde1fc26d8805ac9ede84ef900740","Type":"container","Action":"start","Actor":{"ID":"fd2cd7633f9e9eb6f2df062cfb6587d6802a118febdcf300a6ef7fcfc25b07be","Attributes":{"image":"sha256:ea3f0ec9718aa5d29021b755b489ffb7ab5cde1fc26d8805ac9ede84ef900740","name":"wizardly_elbakyan"}},"scope":"local","time":1636413669,"timeNano":1636413669574048129}
      SonarScanner for MSBuild 5.3.2
      Using the .NET Core version of the Scanner for MSBuild
      Post-processing started.
      Calling the SonarScanner CLI...
      Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.3.2/dotnet-sonarscanner/5.3.2/tools/netcoreapp3.0/any/sonar-scanner-4.6.2.2472/conf/sonar-scanner.properties
      Project root configuration file: /home/tcservice/buildAgent/work/59055310711a86a1/.sonarqube/out/sonar-project.properties
      SonarScanner 4.6.2.2472
      Java 11.0.13 Oracle Corporation (64-bit)
      Linux 4.15.0-156-generic amd64
      User cache: /root/.sonar/cache
      Scanner configuration file: /root/.dotnet/tools/.store/dotnet-sonarscanner/5.3.2/dotnet-sonarscanner/5.3.2/tools/netcoreapp3.0/any/sonar-scanner-4.6.2.2472/conf/sonar-scanner.properties
      Project root configuration file: /home/tcservice/buildAgent/work/59055310711a86a1/.sonarqube/out/sonar-project.properties
      Analyzing on SonarQube server 9.1.0
      Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
      Load global settings
      Load global settings (done) | time=88ms
      Server id: 0F42DFE6-AVkkllZrrqXKE7wEKcq3
      User cache: /root/.sonar/cache
      Load/download plugins
      Load plugins index
      Load plugins index (done) | time=50ms
      Load/download plugins (done) | time=4673ms
      Loaded core extensions: developer-scanner
      Process project properties
      Process project properties (done) | time=27ms
      Execute project builders
      Execute project builders (done) | time=44ms
      Project key: plentyofcode_Matching
      Base dir: /home/tcservice/buildAgent/work/59055310711a86a1
      Working dir: /home/tcservice/buildAgent/work/59055310711a86a1/.sonarqube/out/.sonar
      Load project settings for component key: 'plentyofcode_Matching' (done) | time=54ms
      Load project branches (done) | time=45ms
      Load project pull requests (done) | time=56ms
      Found manual configuration of branch/PR analysis. Skipping automatic configuration.
      Load branch configuration (done) | time=3ms
      Load quality profiles (done) | time=102ms
      Load active rules (done) | time=2792ms
      Pull request 3 for merge into release/2.3.0 from PR1-Test
      SCM collecting changed files in the branch
      ------------------------------------------------------------------------
      EXECUTION FAILURE
      ------------------------------------------------------------------------
      Total time: 9.815s
      Final Memory: 6M/34M
      ------------------------------------------------------------------------
       [91mERROR: Error during SonarScanner execution
       [0m [91mERROR: Not inside a Git work tree: /home/tcservice/buildAgent/work/59055310711a86a1
       [0m [91mERROR: 
       [0m [91mThe SonarScanner did not complete successfully

Also tried setting the base directory to a subdirectory inside the checkout directory but that didn't work either.

Please help! Why isn't the Sonar anaysis detecting .git files?


Solution

  • I forgot I had asked this question. I figured this out after revisiting this after a couple of weeks. The issue was that I had .git on my app's .dockerignore file. After removing it from there, SCM provider autodetection started working again.