sonarqube client - grnet/e-science GitHub Wiki

SonarQube server has been setup on http://83.212.120.11:8008/


Prerequisites

Java (1.8 recommended) If not installed then
sudo gedit /etc/apt/sources.list
Add
# oracle java
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main

Save and
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
then
sudo apt-get update

Finally
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

Sonar Runner

  1. Download latest sonar runner from
    http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/
  2. Save in ~/Downloads (eg. ~/Downloads/sonar-runner-dist-2.4.zip)
  3. sudo cp ~/Downloads/sonar-runner-dist-2.4.zip /opt/
    cd /opt/
    sudo unzip sonar-runner-dist-2.4.zip
    sudo rm sonar-runner-dist-2.4.zip
    sudo gedit /opt/sonar-runner-2.4/conf/sonar-runner.properties
  4. Replace the contents of sonar-runner.properties with
#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
sonar.host.url=http://83.212.120.11:8008

#----- PostgreSQL
sonar.jdbc.url=jdbc:postgresql://83.212.120.11/sonar

#----- Global database settings
sonar.jdbc.username=sonar
sonar.jdbc.password=sonarp@ss

#----- Security (when 'sonar.forceAuthentication' is set to 'true')
sonar.login=developer
sonar.password=escience

\5. Update environment variables
sudo gedit ~/.profile
Add
export SONAR_RUNNER_HOME=/opt/sonar-runner-2.4
PATH="/opt/sonar-runner-2.4/bin:$PATH" then
sudo gedit ~/.bashrc
Add
export SONAR_RUNNER_HOME=/opt/sonar-runner-2.4
Relog the VM or source them both . ~/.profile . ~/.bashrc

Configure the project

  1. Create a sonar-project.properties file at the root of the e-science project (/sonar-project.properties)
  2. Add the following to sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=<your_key>:escience
# this is the name displayed in the SonarQube UI
sonar.projectName=<your_key>
sonar.projectVersion=0.2
# only one laguage can be specified, if multi-language project do not define this property
#sonar.language=java
#sonar.language=py
sonar.java.source=1.8
sonar.py.source=2.7
 
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set. 
# If not set, SonarQube starts looking for source code from the directory containing 
# the sonar-project.properties file. . = 'all'
sonar.sources=webapp/backend,orka/orka/,pithosfs/java
sonar.exclusions=webapp/frontend/app/libs/**,webapp/frontend/tests/**,webapp/frontend/dist/**
 
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

<your_key> must be unique so choose your repo name (eg. sonar.projectKey=ioannisstenos:pithosfs or sonar.projectKey=dimitriskel:pithosfs)
\3. Running Analysis.
Navigate to <e-science> from shell and
sonar-runner

Eclipse/Aptana plugin

  1. Install the plugin
    Help > Eclipse Marketplace > Search: sonarqube > Install
    or
    Help > Install New Software > Work with: http://downloads.sonarsource.com/eclipse/eclipse/ > Select SonarQube, Java, Python > Install
  2. From inside Eclipse/Aptana Menu > Window > Preferences > SonarQube > Servers > Add/Edit > http://83.212.120.11:8008 > Userame: developer Password: escience > Test Connection > Finish
  3. Link project to sonarqube project
    Right-click the java project in Eclipse/Aptana > Configure > Associate with SonarQube: <your_key>
    then
    Right-click the java project in Eclipse/Aptana > SonarQube > Analyze to run a local analysis (results won't be uploaded to SonarQube server)
    You need to shell to /pithosfs/java/ and run sonar-runner to update the server.
⚠️ **GitHub.com Fallback** ⚠️