Sonar-project.properties with SonarCloud BASICS

ALM - Bitbucket Cloud
CI - Bitbucket Cloud
Repo Language - JS (React), NOT TypeScript

Hello All,

I have a fully functional integration between Bitbucket Cloud and SonarCloud. We are using the pipe:

sonarsource/sonarcloud-scan:1.0.1

to access and configure sonarcloud (via the EXTRA_ARGS variable). However, I’ve been asked to surface the configurations we made in SonarCloud’s UI (as well as the arguments in EXTRA_ARGS). The best way to do this is apparently by using the sonar-project.properties file.

My question is, how do I create a basic sonar-project.properties file that is calibrated to be used with Bitbucket Cloud in a JS based repo that uses SonarCloud? I’ve already read the documentation available under SonarScanner that discusses sonar-project.properties, but it wasn’t enough.

I need a better understanding of this file:

  • How to configure it (which properties are mandatory, which optional)
  • Where do I put the file?
  • How to ensure the pipeline will use the file?

Thank you in advanced for any help!

Hi @JasonLunsford and welcome to the community !

Parameters are available here : https://sonarcloud.io/documentation/analysis/analysis-parameters/

You can first copy / paste all your existing params that you pass to the EXTRA_ARGS property and see if you are happy with them.

The file shall be put at the root of your project, or where you are executing the scanner from (but paths should then match correctly)

To be sure that the file is taken into account simply delete all the config from EXTRA_ARGS, you will see if it’s still working.

HTH,
Mickaël

Thank you!

Your advice was more or less exactly what I ended up doing.

For those reading this comment in the future here is the properties file I ended up creating:

Project Meta Data

sonar.organization=organization_is_in_sonarcloud
sonar.projectKey=key_is_displayed_in_sonarcloud
sonar.projectName=your_project_name_here
sonar.projectVersion=latest
sonar.links.homepage=[repo URL]
sonar.links.scm=[repo URL]

Excluded files and folders

sonar.exclusions=node_modules/**/*, reports/**/*

Files and folders to be scanned

sonar.sources=src

Test sources

sonar.testExecutionReportPaths=reports/test-reporter.xml
sonar.javascript.lcov.reportPaths=reports/lcov.info
sonar.test.inclusions=**/*.test.js

Optional Settings

sonar.language=js
sonar.sourceEncoding=UTF-8
sonar.host.url=https://sonarcloud.io

1 Like

Updated documentation link for “Analysis parameters” is here: