Configuration overview

This page explains the hierarchy and provides general configuration guidelines regarding the analysis parameters.

Settings hierarchy

You can configure project analysis settings mainly in the UI, in scanner configuration files, and as scanner arguments on the command line. Here is the hierarchy in order of precedence:

Analysis parameters can be set in (from the lowest to the highest priority) : global properties, project properties, scanner configuration files, scanner arguments on the command line.
  1. Global properties: The Administration > Configuration > General Settings menu in SonarQube UI allows you to configure analysis parameter values that will be used as a default for all projects. For some scanners the properties can be defined in a configuration file. See the individual scanner pages for more information.

  2. Project properties: These properties apply only to the project for which they’re set. You can define them in the UI in the Project Settings > General Settings menu. Changes to the project properties will override the global properties.

  3. Scanner configuration files: You can configure scanner parameters in a configuration file within your project or a build framework. Values set in the configuration file will override project properties set in the UI. See the individual scanner pages for more information.

  4. Scanner arguments: You can also set parameters on the command line used to start the analysis. This can be done with the standalone command-line tool sonar-scanner or with any of the build-tool-specific variants such as SonarScanner for Maven and SonarScanner for Gradle. Scanner arguments override the scanner configuration files.

If you use environment variables, which are available for some properties, they will be overridden by scanner arguments.

There is an exception to this settings hierarchy. You can use two parameters in the UI, Global Source File Exclusions and Global Test File Exclusions, to define the analysis scope at the global level and you cannot override them at the project level. For more details, see Excluding files based on file paths.

General configuration guidelines

Consider the following:

  • Most of the analysis parameters you can set in the UI can also be set in scanner configuration files or as scanner arguments by using the corresponding sonar properties (a sonar property is a key/value pair in which the key has the sonar.<property> syntax) .

  • Sonar property keys are case-sensitive.

  • Some analysis parameters cannot be set in the UI. There are listed in Parameters not settable in the UI.

  • Only parameters you set through the UI are stored in the SonarQube Cloud database. Parameters set in the command line or in the scanner configuration files will only be effective for the current analysis and not for subsequent analyses or analyses in SonarQube for IDE with connected mode. For example, if you override the sonar.exclusions parameter via the command line for a specific project, it will not be stored in the database. Subsequent analyses without the sonar.exclusions parameter in the command line or scanner configuration file, or analyses in SonarQube for IDE, will be executed with the exclusions stored in the database.

  • See the corresponding SonarScanner section in this documentation for general information about the configuration of analysis parameters in scanner configuration files or as scanner arguments:

  • If you use PowerShell, you need to wrap any parameter value that includes a dot (.) in either single or double quotes to prevent misinterpretation.

  • To adjust the analysis scope of your project, see Setting analysis scope.

  • To include test coverage in your project analysis, see Test coverage.

  • To import issues generated by third-party analyzers, see External analyzer reports.

Last updated

Was this helpful?