Manual PR analysis doesn't have GitHub checks posted

Hi there,
I use SonarCloud with a number of repos and one of them doesn’t show a PR check on GitHub. The repos showing it successfully use Gradle integration as per documentation, but the one that’s having troubles is an iOS repo. So this is the only repo explicitly using sonar-scanner to do analysis on our CI.
The analysis is done after all tests are completed and looks like the following:

sonar_args=(
                  "-Dsonar.pullrequest.key=$(System.PullRequest.PullRequestNumber)"
                  "-Dsonar.pullrequest.base=$(System.PullRequest.TargetBranch)"
                  "-Dsonar.pullrequest.branch=$(source-branch)"
                  "-Dsonar.scm.revision=$(git log HEAD@{1} -1 -q | head -1 | cut -f 2 -d' ')"
              )
                      
unitTestReport="$(Pipeline.Workspace)/UnitTestsCoverage/sonarqube-generic-coverage.xml"
uiTestReport="$(Pipeline.Workspace)/UITestsCoverage/sonarqube-generic-coverage.xml"

sonar_args+=(-Dsonar.coverageReportPaths="${unitTestReport},${uiTestReport}")

sonar-scanner "${sonar_args[@]}"

After the analysis completes successfully the comment is posted on the repo, but no check.
Both GitHub repo and SonarCloud are private
My sonar-project.properties looks like this:

sonar.host.url=https://sonarcloud.io
sonar.organization=REDACTED
sonar.projectKey=REDACTED
sonar.login=REDACTED
sonar.sources=Source/
sonar.exclusions=Source/Generated/*

Hi @kohtenko, welcome to the community forum.

Which CI do you use to run the build?
Could you please post the logs produced by the SonarScanner during a pull request analysis?

Thanks
Claire

Hi @Claire_Villard ,
We use AzureDevops, but it shouldn’t make a difference as long as we are triggering sonar-scanner manually. I get the same output on my local terminal. The output with a default INFO level is the following:

2021-03-03T19:49:07.5804940Z INFO: Scanner configuration file: /Users/test/Documents/sonar-scanner/conf/sonar-scanner.properties
2021-03-03T19:49:07.5809920Z INFO: Project root configuration file: /Users/test/Documents/ado-agent/_work/2/s/sonar-project.properties
2021-03-03T19:49:07.6115930Z INFO: SonarScanner 4.6.0.2311
2021-03-03T19:49:07.6117690Z INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
2021-03-03T19:49:07.6118250Z INFO: Mac OS X 10.15.7 x86_64
2021-03-03T19:49:07.8427590Z INFO: User cache: /Users/test/.sonar/cache
2021-03-03T19:49:08.6331770Z INFO: Scanner configuration file: /Users/test/Documents/sonar-scanner/conf/sonar-scanner.properties
2021-03-03T19:49:08.6333930Z INFO: Project root configuration file: /Users/test/Documents/ado-agent/_work/2/s/sonar-project.properties
2021-03-03T19:49:08.6344340Z INFO: Analyzing on SonarCloud
2021-03-03T19:49:08.6347480Z INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
2021-03-03T19:49:09.0481780Z INFO: Load global settings
2021-03-03T19:49:10.1026110Z INFO: Load global settings (done) | time=1056ms
2021-03-03T19:49:10.1081520Z INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
2021-03-03T19:49:10.1109100Z INFO: User cache: /Users/test/.sonar/cache
2021-03-03T19:49:10.1145540Z INFO: Load/download plugins
2021-03-03T19:49:10.1146550Z INFO: Load plugins index
2021-03-03T19:49:10.2487990Z INFO: Load plugins index (done) | time=134ms
2021-03-03T19:49:10.4104990Z INFO: Load/download plugins (done) | time=296ms
2021-03-03T19:49:10.5728580Z INFO: Loaded core extensions: developer-scanner
2021-03-03T19:49:10.8180400Z INFO: JavaScript/TypeScript frontend is enabled
2021-03-03T19:49:10.9932330Z INFO: Found an active CI vendor: 'Azure DevOps'
2021-03-03T19:49:11.0047140Z INFO: Load project settings for component key: 'project_tr-ios'
2021-03-03T19:49:11.1230900Z INFO: Load project settings for component key: 'project_tr-ios' (done) | time=118ms
2021-03-03T19:49:11.1287190Z INFO: Process project properties
2021-03-03T19:49:11.1352060Z INFO: Execute project builders
2021-03-03T19:49:11.1365690Z INFO: Execute project builders (done) | time=2ms
2021-03-03T19:49:11.1388160Z INFO: Project key: project_tr-ios
2021-03-03T19:49:11.1389340Z INFO: Base dir: /Users/test/Documents/ado-agent/_work/2/s
2021-03-03T19:49:11.1390410Z INFO: Working dir: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork
2021-03-03T19:49:11.2479950Z INFO: Load project branches
2021-03-03T19:49:11.3769030Z INFO: Load project branches (done) | time=129ms
2021-03-03T19:49:11.3800520Z INFO: Check ALM binding of project 'project_tr-ios'
2021-03-03T19:49:11.4793870Z INFO: Detected project binding: BOUND
2021-03-03T19:49:11.4798610Z INFO: Check ALM binding of project 'project_tr-ios' (done) | time=100ms
2021-03-03T19:49:11.4824130Z INFO: Load project pull requests
2021-03-03T19:49:11.6354040Z INFO: Load project pull requests (done) | time=153ms
2021-03-03T19:49:11.6385980Z INFO: Load branch configuration
2021-03-03T19:49:12.2197070Z INFO: Load branch configuration (done) | time=581ms
2021-03-03T19:49:12.2455480Z INFO: Load quality profiles
2021-03-03T19:49:12.3897260Z INFO: Load quality profiles (done) | time=144ms
2021-03-03T19:49:12.3942430Z INFO: Load active rules
2021-03-03T19:49:16.1282290Z INFO: Load active rules (done) | time=3733ms
2021-03-03T19:49:16.1432130Z INFO: Organization key: karglobal-project
2021-03-03T19:49:16.1437100Z INFO: Pull request 3525 for merge into master from AB#192249
2021-03-03T19:49:16.1538240Z INFO: SCM collecting changed files in the branch
2021-03-03T19:49:16.4131730Z INFO: SCM collecting changed files in the branch (done) | time=259ms
2021-03-03T19:49:16.4415030Z INFO: Indexing files...
2021-03-03T19:49:16.4416400Z INFO: Project configuration:
2021-03-03T19:49:16.4420950Z INFO:   Excluded sources: Refactory/Generated/*, project3/Assets.xcassets/**/*
2021-03-03T19:49:17.3589020Z INFO: 1750 files indexed
2021-03-03T19:49:17.3590780Z INFO: 1589 files ignored because of inclusion/exclusion patterns
2021-03-03T19:49:17.3591790Z INFO: 0 files ignored because of scm ignore settings
2021-03-03T19:49:17.3599470Z INFO: Quality profile for swift: Sonar way
2021-03-03T19:49:17.3600290Z INFO: Quality profile for web: Sonar way
2021-03-03T19:49:17.3919030Z INFO: ------------- Run sensors on module project_tr-ios
2021-03-03T19:49:17.4751420Z INFO: JavaScript/TypeScript frontend is enabled
2021-03-03T19:49:17.4957900Z INFO: Load metrics repository
2021-03-03T19:49:17.6085580Z INFO: Load metrics repository (done) | time=113ms
2021-03-03T19:49:19.1695370Z INFO: Sensor SonarCSS Rules [cssfamily]
2021-03-03T19:49:21.2029750Z INFO: 1 source files to be analyzed
2021-03-03T19:49:21.3217840Z INFO: 1/1 source files have been analyzed
2021-03-03T19:49:21.3218590Z INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=2152ms
2021-03-03T19:49:21.3221700Z INFO: Sensor C# Project Type Information [csharp]
2021-03-03T19:49:21.3249980Z INFO: Sensor C# Project Type Information [csharp] (done) | time=3ms
2021-03-03T19:49:21.3252840Z INFO: Sensor C# Properties [csharp]
2021-03-03T19:49:21.3262130Z INFO: Sensor C# Properties [csharp] (done) | time=1ms
2021-03-03T19:49:21.3265560Z INFO: Sensor JavaXmlSensor [java]
2021-03-03T19:49:21.3344710Z INFO: Sensor JavaXmlSensor [java] (done) | time=8ms
2021-03-03T19:49:21.3346110Z INFO: Sensor HTML [web]
2021-03-03T19:49:21.4506960Z INFO: Sensor HTML [web] (done) | time=116ms
2021-03-03T19:49:21.4509530Z INFO: Sensor VB.NET Project Type Information [vbnet]
2021-03-03T19:49:21.4527660Z INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=2ms
2021-03-03T19:49:21.4530020Z INFO: Sensor VB.NET Properties [vbnet]
2021-03-03T19:49:21.4537330Z INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
2021-03-03T19:49:21.4539730Z INFO: Sensor Swift Code Quality and Security [swift]
2021-03-03T19:49:21.4564820Z INFO: 1397 source files to be analyzed
2021-03-03T19:49:31.4618910Z INFO: 214/1397 files analyzed, current file: project3/TradeViewController.swift
2021-03-03T19:49:41.4717630Z INFO: 650/1397 files analyzed, current file: Refactory/Features/AutoDecision/TradeViewAutoCheckoutView.swift
2021-03-03T19:49:51.4816780Z INFO: 1179/1397 files analyzed, current file: Refactory/Shared/Protocols/AlertDisplaying.swift
2021-03-03T19:49:56.0122110Z INFO: 1397/1397 source files have been analyzed
2021-03-03T19:49:56.0125750Z INFO: Sensor Swift Code Quality and Security [swift] (done) | time=34559ms
2021-03-03T19:49:56.0128740Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2021-03-03T19:49:56.0178680Z INFO: '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
2021-03-03T19:49:56.0183990Z INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
2021-03-03T19:49:56.0185370Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=6ms
2021-03-03T19:49:56.0186460Z INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
2021-03-03T19:49:56.0219950Z INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=3ms
2021-03-03T19:49:56.0221060Z INFO: Sensor Generic Coverage Report
2021-03-03T19:49:56.0224930Z INFO: Parsing /Users/test/Documents/ado-agent/_work/2/UnitTestsCoverage/sonarqube-generic-coverage.xml
2021-03-03T19:49:56.5506460Z INFO: Imported coverage data for 1230 files
2021-03-03T19:49:56.5507820Z INFO: Coverage data ignored for 2 unknown files, including:
2021-03-03T19:49:56.5509240Z project3UnitTests/MockAppDelegate.swift
2021-03-03T19:49:56.5510120Z main.swift
2021-03-03T19:49:56.5511770Z INFO: Parsing /Users/test/Documents/ado-agent/_work/2/UITestsCoverage/sonarqube-generic-coverage.xml
2021-03-03T19:49:57.2277200Z INFO: Imported coverage data for 1230 files
2021-03-03T19:49:57.2278680Z INFO: Coverage data ignored for 2 unknown files, including:
2021-03-03T19:49:57.2279580Z project3UnitTests/MockAppDelegate.swift
2021-03-03T19:49:57.2280160Z main.swift
2021-03-03T19:49:57.2280820Z INFO: Sensor Generic Coverage Report (done) | time=1206ms
2021-03-03T19:49:57.2282010Z INFO: Sensor JavaSecuritySensor [security]
2021-03-03T19:49:57.2286700Z INFO: Reading type hierarchy from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/java
2021-03-03T19:49:57.2287420Z INFO: Read 0 type definitions
2021-03-03T19:49:57.2310130Z INFO: Reading UCFGs from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/java
2021-03-03T19:49:57.2314480Z INFO: No UCFGs have been included for analysis.
2021-03-03T19:49:57.2315670Z INFO: Sensor JavaSecuritySensor [security] (done) | time=4ms
2021-03-03T19:49:57.2317820Z INFO: Sensor CSharpSecuritySensor [security]
2021-03-03T19:49:57.2319620Z INFO: Reading type hierarchy from: /Users/test/Documents/ado-agent/_work/2/s/ucfg_cs2
2021-03-03T19:49:57.2320720Z INFO: Read 0 type definitions
2021-03-03T19:49:57.2322470Z INFO: Reading UCFGs from: /Users/test/Documents/ado-agent/_work/2/s/ucfg_cs2
2021-03-03T19:49:57.2323360Z INFO: No UCFGs have been included for analysis.
2021-03-03T19:49:57.2324400Z INFO: Sensor CSharpSecuritySensor [security] (done) | time=0ms
2021-03-03T19:49:57.2325250Z INFO: Sensor PhpSecuritySensor [security]
2021-03-03T19:49:57.2327360Z INFO: Reading type hierarchy from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/php
2021-03-03T19:49:57.2328270Z INFO: Read 0 type definitions
2021-03-03T19:49:57.2330010Z INFO: Reading UCFGs from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/php
2021-03-03T19:49:57.2331010Z INFO: No UCFGs have been included for analysis.
2021-03-03T19:49:57.2332130Z INFO: Sensor PhpSecuritySensor [security] (done) | time=0ms
2021-03-03T19:49:57.2332920Z INFO: Sensor PythonSecuritySensor [security]
2021-03-03T19:49:57.2334440Z INFO: Reading type hierarchy from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/python
2021-03-03T19:49:57.2335370Z INFO: Read 0 type definitions
2021-03-03T19:49:57.2336880Z INFO: Reading UCFGs from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/python
2021-03-03T19:49:57.2337900Z INFO: No UCFGs have been included for analysis.
2021-03-03T19:49:57.2338830Z INFO: Sensor PythonSecuritySensor [security] (done) | time=1ms
2021-03-03T19:49:57.2339650Z INFO: Sensor JsSecuritySensor [security]
2021-03-03T19:49:57.2341070Z INFO: Reading type hierarchy from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/js
2021-03-03T19:49:57.2341920Z INFO: Read 0 type definitions
2021-03-03T19:49:57.2343280Z INFO: Reading UCFGs from: /Users/test/Documents/ado-agent/_work/2/s/.scannerwork/ucfg2/js
2021-03-03T19:49:57.2344180Z INFO: No UCFGs have been included for analysis.
2021-03-03T19:49:57.2363380Z INFO: Sensor JsSecuritySensor [security] (done) | time=0ms
2021-03-03T19:49:57.2378260Z INFO: ------------- Run sensors on project
2021-03-03T19:49:57.2519780Z INFO: Sensor Zero Coverage Sensor
2021-03-03T19:49:57.2818620Z INFO: Sensor Zero Coverage Sensor (done) | time=30ms
2021-03-03T19:49:57.2868330Z INFO: SCM Publisher SCM provider for this project is: git
2021-03-03T19:49:57.2875420Z INFO: SCM Publisher 1 source file to be analyzed
2021-03-03T19:49:57.5742130Z INFO: SCM Publisher 1/1 source file have been analyzed (done) | time=286ms
2021-03-03T19:49:57.7079890Z INFO: CPD Executor 207 files had no CPD blocks
2021-03-03T19:49:57.7081280Z INFO: CPD Executor Calculating CPD for 1191 files
2021-03-03T19:49:58.0753280Z INFO: CPD Executor CPD calculation finished (done) | time=367ms
2021-03-03T19:49:58.3873930Z INFO: SCM writing changed lines
2021-03-03T19:49:58.4301640Z INFO: SCM writing changed lines (done) | time=42ms
2021-03-03T19:49:58.6477790Z INFO: Analysis report generated in 441ms, dir size=1 MB
2021-03-03T19:50:00.5832130Z INFO: Analysis report compressed in 1935ms, zip size=1 MB
2021-03-03T19:50:01.6280870Z INFO: Analysis report uploaded in 1045ms
2021-03-03T19:50:01.7320520Z INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=project_tr-ios&pullRequest=3525
2021-03-03T19:50:01.7322100Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2021-03-03T19:50:01.7323200Z INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AXf5o9va7Q7kA315kqg_
2021-03-03T19:50:02.3620980Z INFO: Analysis total time: 51.789 s
2021-03-03T19:50:02.3649830Z INFO: ------------------------------------------------------------------------
2021-03-03T19:50:02.3650520Z INFO: EXECUTION SUCCESS
2021-03-03T19:50:02.3651340Z INFO: ------------------------------------------------------------------------
2021-03-03T19:50:02.3651790Z INFO: Total time: 54.786s
2021-03-03T19:50:02.5406370Z INFO: Final Memory: 126M/434M
2021-03-03T19:50:02.5408010Z INFO: ------------------------------------------------------------------------
2021-03-03T19:50:02.5877310Z ##[section]Finishing: SonarCloud

Please let me know if DEBUG level output is needed

Hi,

For the example of build without check, the SHA of the decorated commit was 807d98678b2c35d7d90f5d3c1c9e0d124db91cb7. Is it correct, related to the build? Is it the commit you expect the check to be reported to?

The SonarScanner is supposed to detect the analyzed commit SHA directly from the .git directory of the cloned repository. Could you please explain why you had to configure manually the sonar.scm.revision property? A mismatch between the value of that property and the commit on GitHub may explain why the check is missing (or reported to another commit).

1 Like

Thanks a lot @Claire_Villard , that was it! I didn’t know this property is optional. There’s little to none documentation I could find regarding manual analysis and the properties related. I assumed it was required, because it is on CodeClimate which we just have migrated from. I now see the check!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.