I tried to use SonarCloud plugin in Azure DevOps but I couldn’t make the code coverage work.
When I use sonar-scanner - npm (npmjs.com), it works like a charm. Could you help to look into it?
- ALM used (GitHub, Bitbucket Cloud, Azure DevOps)
Azure DevOps
- CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI
Azure DevOps
- Scanner command used when applicable (private details masked)
- task: SonarCloudPrepare@1
displayName: "Prepare analysis on SonarCloud"
inputs:
SonarCloud: *****
organization: orsted
projectKey: *****
scannerMode: CLI
cliProjectKey: *****
cliSources: src
configMode: manual
extraProperties: |
sonar.verbose=true
sonar.sourceEncoding=UTF-8
sonar.language=ts
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.exclusions=**/*.spec.ts,**/*.js
sonar.coverage.exclusions=src/main.ts,src/polyfills.ts,**/*environment*.ts,**/*module.ts
sonar.testExecutionReportPaths=$(System.DefaultWorkingDirectory)/test-results/sonarcloud-report.xml
sonar.javascript.lcov.reportPaths=$(System.DefaultWorkingDirectory)/test-results/coverage/lcov.info
- task: SonarCloudAnalyze@1
displayName: "Run SonarCloud analysis"
- task: SonarCloudPublish@1
displayName: "Publish results on build summary"
- Languages of the repository
Typescript
-
Only if the SonarCloud project is public, the URL
- And if you need help with pull request decoration, then the URL to the PR too
Nope, not public
- Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
Log for lcov being picked up:
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
INFO: Linux 5.11.0-1021-azure amd64
DEBUG: SonarCloud 9.0.1.46107
[...]
17:19:40.157 DEBUG: Adding rules for repository 'jssecurity', language: JAVASCRIPT, [class com.sonar.security.frontend.js.rules.DomOpenRedirectCheck, class com.sonar.security.frontend.js.rules.DomXssCheck, class com.sonar.security.frontend.js.rules.DynamicCodeExecutionCheck, class com.sonar.security.frontend.js.rules.FilePathInjectionCheck, class com.sonar.security.frontend.js.rules.HttpRedirectionCheck, class com.sonar.security.frontend.js.rules.NoSQLInjectionCheck, class com.sonar.security.frontend.js.rules.OSArgumentConstructionCheck, class com.sonar.security.frontend.js.rules.OSArgumentInjectionCheck, class com.sonar.security.frontend.js.rules.OSCommandInjectionCheck, class com.sonar.security.frontend.js.rules.ReflectedXssCheck, class com.sonar.security.frontend.js.rules.RegularExpressionDoSCheck, class com.sonar.security.frontend.js.rules.ServerSideRequestCheck, class com.sonar.security.frontend.js.rules.SQLInjectionCheck, class com.sonar.security.frontend.js.rules.ZipSlipCheck, class com.sonar.security.frontend.js.rules.SessionFixationCheck] from com.sonar.security.frontend.js.D
17:19:40.170 DEBUG: Adding rules for repository 'tssecurity', language: TYPESCRIPT, [class com.sonar.security.frontend.js.rules.DomOpenRedirectCheck, class com.sonar.security.frontend.js.rules.DomXssCheck, class com.sonar.security.frontend.js.rules.DynamicCodeExecutionCheck, class com.sonar.security.frontend.js.rules.FilePathInjectionCheck, class com.sonar.security.frontend.js.rules.HttpRedirectionCheck, class com.sonar.security.frontend.js.rules.NoSQLInjectionCheck, class com.sonar.security.frontend.js.rules.OSArgumentConstructionCheck, class com.sonar.security.frontend.js.rules.OSArgumentInjectionCheck, class com.sonar.security.frontend.js.rules.OSCommandInjectionCheck, class com.sonar.security.frontend.js.rules.ReflectedXssCheck, class com.sonar.security.frontend.js.rules.RegularExpressionDoSCheck, class com.sonar.security.frontend.js.rules.ServerSideRequestCheck, class com.sonar.security.frontend.js.rules.SQLInjectionCheck, class com.sonar.security.frontend.js.rules.ZipSlipCheck, class com.sonar.security.frontend.js.rules.SessionFixationCheck] from com.sonar.security.frontend.js.B
[...]
INFO: 268/268 source files have been analyzed
INFO: Sensor TypeScript analysis [javascript] (done) | time=22045ms
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
DEBUG: Using '/home/vsts/work/1/s/test-results/coverage/lcov.info' to resolve LCOV files
INFO: Analysing [/home/vsts/work/1/s/test-results/coverage/lcov.info]
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=48ms
INFO: Sensor CSS Metrics [javascript]
INFO: Sensor CSS Metrics is restricted to changed files only
[...]
DEBUG: SCM reported changed lines for 6 files in the branch
INFO: SCM writing changed lines (done) | time=176ms
INFO: Analysis report generated in 788ms, dir size=358 KB
INFO: Analysis report compressed in 258ms, zip size=247 KB
INFO: Analysis report generated in /home/vsts/work/1/s/.scannerwork/scanner-report
DEBUG: Upload report
DEBUG: POST 200 https://sonarcloud.io/api/ce/submit?**** | time=193ms
INFO: Analysis report uploaded in 196ms
DEBUG: Report metadata written to /home/vsts/work/_temp/sonar/****/report-task.txt
INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?****
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=****
DEBUG: Post-jobs :
DEBUG: eslint-bridge server will shutdown