Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 112 Next »

Table of Contents

 

For an overview of the Sonar technical architecture, browse this page.

Install the Sonar Runner or Analyzer

The Sonar Analyzer can be triggered by 4 different bootstrappers: Sonar Runner, Maven, Ant or Gradle.

Sonar Runner

Prerequisites

  • Java 1.5 or higher
  • Sonar 2.6 or higher

Download

Installation

  1. Uncompress the downloaded file into a directory named $SONAR_RUNNER_HOME in the next steps.
  2. Update the global settings (database connection, server URL) by editing the file $SONAR_RUNNER_HOME/conf/sonar-runner.properties
  3. Add the $SONAR_RUNNER_HOME/bin directory to your path.
  4. You can check the basic installation by opening a new shell and executing the command 'sonar-runner -h' (on windows platform the command is 'sonar-runner.bat -h') . You should get a message like this :

If you need more debug information you can add the property sonar.verbose by adding the command line parameter -Dsonar.verbose=true.

You are now ready to analyze a project with the Sonar Runner.

Release Notes

com.atlassian.confluence.macro.MacroExecutionException: JIRA project does not exist or you do not have permission to view it.

com.atlassian.confluence.macro.MacroExecutionException: JIRA project does not exist or you do not have permission to view it.

com.atlassian.confluence.macro.MacroExecutionException: JIRA project does not exist or you do not have permission to view it.

com.atlassian.confluence.macro.MacroExecutionException: JIRA project does not exist or you do not have permission to view it.

Maven

Install

Download and install Maven 2.0.10, 2.1.x, 2.2.x or 3.x.

Global settings

Edit the settings.xml file, located in $MAVEN_HOME/conf or ~/.m2, to set the database parameters to be used as well as the Sonar server URL.

Example:

Icon

Warning: With Sonar 2.2, the property sonar.host.url MUST NOT end with a slash character. Otherwise, JDBC driver is not found by the Sonar Maven plugin. See SONAR-1685.

It is recommended to increase the Java heap memory. It avoids getting OutOfMemoryError failures. Set the MAVEN_OPTS environment variable:

You are now ready to analyze a project with Maven.

Ant Task

Prerequisites

  • Ant 1.7.1 or higher
  • Java 1.5 or higher
  • Sonar 2.8 or higher

Version compatibility

Ant task

Sonar 2.6

Sonar 2.7

Sonar 2.8

Sonar 2.9 to Sonar 3.0

1.4

(error)

(error)

(tick)

(tick)

1.3

(error)

(error)

(tick)

(tick)

1.2

(error)

(error)

(tick)

(tick)

1.1

(error)

(error)

(tick)

(tick)

1.0

(tick)

(tick)

(tick) but without support of multi-modules

(error)

The way to configure the Sonar Ant task has changed between version 1.0 and version 1.1, so if you must use the Ant task version 1.0, please use this documentation page.

Older versions of Sonar are not supported.

Installation

  1. Download the Sonar Ant Task
  2. Declare the Sonar Ant Task and define the configuration in a common Ant script file:

    You are now ready to analyze a project with the Ant task.

     

 

Release Notes

Loading

Release 1.4 (4 issues)

Loading

Release 1.3 (2 issues)

Loading

Release 1.2 (2 issues)

Loading

Release 1.1 (3 issues)

 

Loading

Release 1.0 (1 issues)

T Key Summary P Status Resolution
New Feature SONARPLUGINS-950 New ANT task to analyze projects Critical Closed Fixed

 

Gradle

To be done.

Install Sonar

Download and unzip the distribution.

Database

Install Database

Apache Derby is shipped with Sonar. It does not need any installation. It's great for demos and tests but we advice you to use a robust database for real use. See the supported platforms for more information.

To use one of the external databases, it is necessary to explicitly set up the initial database schema and permissions. Tables and indexes will then be automatically created when launching Sonar for the first time. Example scripts for setting MySQL up can be found in extras/database/mysql.

Character Set

Icon

When creating a database, the recommended character set is UTF-8.

Collation

Icon

Collation must be case-sensitive. It must also be accent-sensitive in Microsoft SQL Server.

Configure Database

If you do not use the default embedded database, edit conf/sonar.properties to configure the database access. Templates are available for every supported database. Just uncomment them and comment the first four lines dedicated to derby.

  • sonar.jdbc.url : the URL of the database
  • sonar.jdbc.driver : the class of the driver
  • sonar.jdbc.user : the username (default value is 'sonar')
  • sonar.jdbc.password : the password (default value is 'sonar')

Example for MySQL:

For Oracle, copy the JDBC driver to /extensions/jdbc-driver/[YOUR DATABASE]/. Other drivers for supported database are already provided.

Start Sonar Server

Mode 1 - Start the standalone application

The default listen port is 9000, the default context path is / and Sonar listens by default to all network interfaces : '0.0.0.0'. Once launched, the Sonar web server is available on http://localhost:9000. Parameters can be changed into the file conf/sonar.properties. Here is an example to listen to http://localhost:80/sonar :


Execute the following script to start the server :

Note that you can also run as a NT service with bin/windows-x86-32/InstallNTService.bat then bin/windows-x86-32/StartNTService.bat

You can now browse to http://localhost:9000.

Mode 2 - Deploy on JEE Server

Sonar can be packaged as a WAR then deployed into an existing JEE server. To use this method of installation, you must already know how to deploy a web application on the application server of choice. The supported servers are Tomcat 5.x, 6.x, 7.x and Jetty 6.x.

Installation steps are :

  • Edit conf/sonar.properties as described in standalone mode. The file conf/wrapper.conf is never used when deploying to application server.
  • Execute the script build-war.sh (or build-war.bat on MS Windows) from the directory war/
  • Deploy war/sonar.war to the application server
  • Browse to http://localhost/sonar and follow setup instructions

You can inject environment variables in the "sonar.properties" file

Icon

You have a specific syntax for that. For instance, to inject the JDBC connection string:

This can be quite valuable to better handle production environments.

Icon

A minimum heap size of 512Mb is required. To increase memory heap size on Tomcat, set the CATALINA_OPTS variable before starting Tomcat

Prior to Sonar 2.2, the WAR file must be rebuilt each time the configuration is updated (new plugins or new extensions).
From Sonar 2.2 onwards, the WAR file is now linked to the Sonar directory (the directory where the distribution is unzipped). It implies that :

  • the directory where the distribution is unzipped cannot be removed
  • there is no need to rebuild the WAR when installing/uninstalling plugins or rule extensions
  • the WAR file must be deployed on the host which contains the Sonar directory
  • the WAR file must be rebuilt when the Sonar directory is moved
  • the WAR file must be rebuilt when a configuration file is updated (directory conf/)

    Icon

    The user who runs Tomcat must have read & write access to Sonar home directory (to allow plugin install from the Web admin console for instance).

More details on this blog.

Mode 3 - Run as a service on MS Windows

Install/uninstall NT service (may have to run these batch files via "Run As Administrator"):

Start/stop the service :

 

Mode 4 - Run as a service on Linux

The following has been tested on Ubuntu 8.10 and CentOS 6.2.

Create the file /etc/init.d/sonar with this content :

Register Sonar at boot time (Ubuntu, 32 bit):

Register Sonar at boot time (RedHat, CentOS, 64 bit):

Advanced Intallation

To run Sonar behind a proxy, browse this page.

  • No labels