The SonarQube Runner allows us to perform source code analyzes without using tools such as Ant or Maven.
These toos are well known from J2EE (or any other new technology) development teams, but let’s remember that our objective in this serie about the installation of SonarQube, and more generally in our blog, is to allow anyone to perform code quality and applications analyzes, without requiring any knowledge of these new technologies.
How many technical directors, Quality consultants, Mainframe Cobol or SAP project managers, DBAs, member or responsable of QA teams, and IT managers or stakeholders, how many consider that Open Source tools such as SonarQube are reserved for J2EE experts? I know some of them.
With the SonarQube-Runner, and also a tool like Jenkins that we will see nextly, everyone can analyze all kinds of languages, not just Java. And without knowing anything about new technologies, or at least a minimal knowledge easy to acquire (for instance, through my blog).
Installing SonarQube Runner
We will first download the installation file from the SonarQube Runner page: Installing and Configuring SonarQube Runner. In my case, at the time of this post, it will be the version 2.1.
We decompress this file in a folder ‘sonar-runner-2.1’ (thus in ‘C:\Soft\Sonar\sonar-runner-2.1’ in my environement).
In this folder, we look for the ‘\conf’ directory to find the file ‘sonar-runner.properties’.
We will use this properties file to manage the connection to the SonarQube application under Tomcat. In fact, we just have to indicate the same parameters as during the SonarQube installation.
First the SonarQube server url:
#—– Default Sonar server
sonar.host.url=http://localhost:8888/sonar/
And then the information to connect our database. The connection string consists of the jdbc driver, our server (‘localhost’) and the database JPORA11 on the default port 1521 of Oracle.
#—– Oracle
sonar.jdbc.url: jdbc:oracle:thin:@localhost:1521/JPORA11
#—– Global database settings
Then we indicate the Oracle user and his password, to access the ‘sonar’ schema.
sonar.jdbc.username: sonar
sonar.jdbc.password: sonar
Et voilà. To run the SonarQube Runner, you just have to launch the ‘sonar-runner.bat’ file located into the ‘..\bin’ directory. We will see that in our first SonarQube analysis.
If you want to try by yourself, or if you want to get some code samples to test, SonarSource provides several examples from this page. You will also find examples of analysis configuration with the SonarQube Runner, for different programming languages.
I let you navigate this page and search which may possibly interest you. Next post will be about our first analysis with SonarQube Runner.
This post is also available in Leer este articulo en castellano and Lire cet article en français.