SonarQube

The SonarQube bundled plugin runs static analysis against source code in a repository and reports findings and metrics. You can use it to analyze your source code on every changeset, or on a regular schedule, and optionally record the defects and metrics on your SonarQube server.

Prerequisites

Before you can use the SonarQube plugin, ensure that you fulfill the following prerequisites:

  • On your PulseUno server, install and configure the SonarScanner command-line application.

  • Install a SonarQube server on your network (not necessarily on the PulseUno server).

  • Create and set up the server configuration file ${dataDir}/conf/experts/com.serena.starlight/sonarqube/sonarqube-pulse-expert.properties.

  • SonarQube plugin uses the Web Service Java Client to make REST requests to a SonarQube server. For supported SonarQube versions, see the Support Matrix.

Back to top

Create server configuration file

The SonarQube plugin properties file is required and is located in:

${dataDir}/conf/experts/com.serena.starlight/sonarqube/sonarqube-pulse-expert.properties

Property Description
sonar.host.url

Enter the SonarQube server URL, for example:

http://localhost:9000

pulse.sonar.agent.path

Enter the full path to the SonarScanner application, for example:

C:\\sonar-scanner\\bin\\sonar-scanner.bat

sonar.jdbc.url

Specify the JDBC connection URL for the SonarQube database, for example:

jdbc:h2:tcp://localhost:9092/sonar

sonar.jdbc.username

Specify the database username for the JDBC connection.

sonar.jdbc.password

Specify the database password for the JDBC connection.

pulse.results.delay

When SonarQube analyzes code that produces a large number of findings (2000), a short delay is needed before the results can be fetched. Normally, this delay is required only on the first run. On subsequent runs only the delta needs to be updated.

Default: 30 seconds.

If you do not specify an optional property, SonarScanner uses the default value from the properties file:

${install_directory}/conf/sonar-scanner.properties

where ${install_directory} is the SonarScanner installation location.

You can configure additional supported parameters in the sonar-scanner.properties file.

Back to top

Configure plugin settings

Because the SonarScanner operates on source code files, add the SonarQube plugin to a chain that populates a workspace.

When you add the Visual SonarQube plugin step to a chain, specify the following configuration details:

Field Description
Title Enter a name for this step in the chain. Default: SonarQube.
Project configuration
Source folder

Enter the stream directory against which to run the analysis.

Relative stream folder in the workspace (Optional) Enter the relative path to the stream directory in the workspace.
Path to SonarQube Scanner workspace

(Optional) Enter the path to the SonarScanner workspace.

Default path: .sonar

Project key

Specify the unique SonarQube project key. Typically, this is the value defined for<groupId>:<artifactId> in Maven, for example:

example-key
com.example:project1

Project name Specify the name of the SonarQube project that will be displayed in the web browser. Typically, this is the value defined for <name> in Maven.
Project version Specify the SonarQube project version. Typically, this is the value defined for <version> in Maven, for example, 1.0.
Project properties (Optional) Enter project properties that will override the settings in sonar-scanner.properties or sonar-project.properties files.
Project properties file (Optional) Specify a full path to the project properties file.
Analysis configuration
Analysis mode Select an analysis mode:
  • publish
  • preview
  • issues
Client configuration
Full path to the SonarQube Scanner application

(Optional) Enter the full path to the SonarScanner application, for example:

C:\\sonar-scanner\\bin\\sonar-scanner.bat

Full path to sonar-scanner.properties (Optional) Enter the full path to the SonarScanner properties file.
Server configuration
SonarQube Server URL

(Optional) Enter the URL of the SonarQube server.

Default: http://localhost:9000

Username (Optional) Enter the username to connect to the SonarQube server.
Password (Optional) Enter the password to connect to the SonarQube server.

The properties Username and Password are optional and are only required in specific security situations. For details, see the SonarQube help.

The properties Project key, Project name and Project version are optional if they have been set in the properties file or the Project Properties box.

Back to top

See also: