SonarQube Scanner Setup
1. Get SonarQube Scanner
1.1 Visit SonarQube official site for the latest version; if you are using SonarQube 5.5 or earlier, visit the archived runner page to get runner-2.4 (notice that sonar-runner is the previous version of sonar-scanner)
1.2 Download the required version for Windows to your Downloads folder
2. Extracts to C:\sonarqube
2.1 Extracts the downloaded file to C:\sonarqube\scanner-3.x using your preferred unzip program
3. Define system variables
3.1 Open system properties dialog
3.2 Select Advanced System Settings
3.3 Click on Environment Variables... button
3.4 On the Envirnoment Variable dialog, click on system variables New... button
3.5 Define the SONAR_SCANNER_HOME variable
3.6 Accept changes and edit the system variable Path to add ;%SONAR_SCANNER_HOME%\bin at the end
3.7 Accept changes and close all dialogs
3.8 Depending on you Windows version, you need to restart to apply the changes
4. Setup SonarQube Scanner properties
4.1 Configure the server URL
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
# Following line must refer to the SonarQube installation, either if in localhost or not
sonar.core.serverBaseURL=http://localhost:9000
#---- objectscriptQuality plugin
# Define default encoding of files; if not set, the system encoding is used
#sonar.objectscript.encode=UTF-8
If you are using SonarQube 5.2 or lower version, you will have to include some additional properties: sonar.jdbc.url, sonar.jdbc.username, sonar.jdbc.password
If you are using SonarQube 5.2 or lower version, must use sonar.host.url instead sonar.core.serverBaseURL
5. Quick check
5.1 A quick sonar-scanner check
> sonar-scanner --version
C:\sonarqube\scanner-3.x
SonarQube Scanner 3.2.0.1227
Java 1.8.0_181 Oracle Corporation (64-bit)
Windows NT (unknown) 10.0 amd64
1. Get SonarQube Scanner
1.1 Visit SonarQube official site for the latest version; if you are using SonarQube 5.5 or earlier, visit the archived runner page to get runner-2.4 (notice that sonar-runner is the previous version of sonar-scanner)
1.2 Download the latest version via wget command to /tmp folder
$ wget -P /tmp https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.0.2311-linux.zip
2. Extracts to /opt/sonarqube/
2.1 Extracts the downloaded file to /opt/sonarqube
$ sudo unzip /tmp/sonar-scanner-cli-4.6.0.2311-linux.zip -d /opt/sonarqube
$ ls -la /opt/sonarqube/sonar-scanner-4.6.0.2311-linux
total 24
drwxr-xr-x 6 root root 4096 May 12 12:49 .
drwxr-xr-x 6 sonar sonar 4096 Aug 25 17:07 ..
drwxr-xr-x 2 root root 4096 May 12 12:49 bin
drwxr-xr-x 2 root root 4096 Aug 25 15:28 conf
drwxr-xr-x 4 root root 4096 Aug 25 15:28 jre
drwxr-xr-x 2 root root 4096 Aug 25 15:28 lib
3. Define a symbolic link to SonarQube Scanner
3.1 For easy upgrades on future it is highly recommended to create the symbolic link
$ sudo ln -s
/opt/sonarqube/sonar-scanner-4.6.0.2311-linux
/opt/sonarqube/sonar-scanner
4. Setup SonarQube Scanner properties
4.1 Configure the server URL
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
# Following line must refer to the SonarQube installation, either if in localhost or not
sonar.core.serverBaseURL=http://localhost:9000
#---- objectscriptQuality plugin
# Define default encoding of files; if not set, the system encoding is used
#sonar.objectscript.encode=UTF-8
If you are using SonarQube 5.2 or lower version, you will have to include some additional properties: sonar.jdbc.url, sonar.jdbc.username, sonar.jdbc.password
If you are using SonarQube 5.2 or lower version, must use sonar.host.url instead sonar.core.serverBaseURL
5. Add SonarQube Scanner to PATH
5.1 If you want to execute SonarQube Scanner from command line, it is recommended to add to your PATH
JAVA_HOME=/opt/java/default-jdk/
export JAVA_HOME
SONAR_SCANNER_HOME=/opt/sonarqube/sonar-scanner
export SONAR_SCANNER_HOME
PATH="$JAVA_HOME/bin:$SONAR_SCANNER_HOME/bin:$PATH"
export PATH