Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday 24 November 2019

How To Configure SonarQube on Ubuntu 16.04



Q. What is SonarQube ?

-- SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages. SonarQube offers reports on duplicated code, coding standards, unit tests, code coverage, code complexity, comments, bugs, and security vulnerabilities.

SonarQube includes support for the programming languages Java (including Android), C#, PHP, JavaScript, TypeScript, C/C++, Ruby, Kotlin, Go, COBOL, PL/SQL, PL/I, ABAP, VB.NET, VB6, Python, RPG, Flex, Objective-C, Swift, CSS, HTML, and XML.


Requirements:
  • Ubuntu 16.04 Server
  • 2 GB of RAM to run efficiently and 1 GB of free RAM (Preferred 4 GB RAM) 
  • Disk Space: Depending on utilization (Preferred 50 GB) 
  • Instance volume type must be excellent read & write performance 
  • SonarQube does not support 32-bit systems on the server side. 
  • Open JDK 8 or Oracle Java 8
  • Database MySQL 5.7 (Preferred MSSQL)

Installation:

Step: 1. Update System & Install required Packages :

# apt-get update && apt-get -y upgrade
# apt-get -y install -y wget unzip zip
 

Step: 2.  Install Oracle Java :

# cd /opt
# mkdir java
# wget https://github.com/frekele/oracle-java/releases/download/8u212-b10/jdk-8u212-linux-x64.tar.gz
# tar -xzvf jdk-8u212-linux-x64.tar.gz -C /opt/java --strip-components=1
# update-alternatives --install /usr/bin/java java /opt/java/bin/java 100
# update-alternatives --install /usr/bin/javac javac /opt/java/bin/javac 100
# java -version
# echo $JAVA_HOME

Step: 3. Create user for SonarQube :

 
# sudo adduser --system --no-create-home --group --disabled-login sonarqube


Step: 4. Install MySQL Server & Create User for SonarQube :

 
# apt-get -y install mysql-server-5.7 mysql-server-core-5.7

# mysql_secure_installation

# mysql -u root -p

Enter Password:

MySQL> CREATE DATABASE sonardb CHARACTER SET utf8 COLLATE utf8_bin;
MySQL> GRANT ALL on sonardb.* TO 'sonarqube'@'localhost' IDENTIFIED BY 'sonardb#321';
MySQL> FLUSH PRIVILEGES;
MySQL> exit;


Step: 5. Install SonarQube :

 
# cd /opt/
# wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.7.zip
# unzip sonarqube-7.7.zip
# mv sonarqube-7.7 sonarqube
# sudo chown -R sonarqube:sonarqube /opt/sonarqube
# vi sonarqube/conf/sonar.properties

     sonar.jdbc.username=sonarqube
     sonar.jdbc.password=sonardb#321
     sonar.jdbc.url=jdbc:mysql://localhost:3306/sonardb?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
     sonar.web.javaOpts=-server
     sonar.web.host=0.0.0.0
     sonar.web.port=9000
     sonar.web.context=/sonarqube (for If you want to web access like https://www.example.com/sonarqube)


-- Save & Quit (:wq)


Step: 6. Create Service for SonarQube :

 
# vi /etc/systemd/system/sonarqube.service
 
  [Unit]
  Description=SonarQube service
  After=syslog.target network.target

  [Service]
  Type=forking

  ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
  ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop

  User=sonarqube
  Group=sonarqube
  Restart=always

  [Install]
  WantedBy=multi-user.target


-- Save & Quit (:wq)

# systemctl daemon-reload

Step: 7. SonarQube Service Commands :

 
# service sonarqube start
# service sonarqube status
# service sonarqube stop

Step: 8. Install SonarScanner for Scanning :

 
# cd /opt
# wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip
# unzip sonar-scanner-cli-3.3.0.1492-linux.zip
# mv sonar-scanner-3.3.0.1492-linux sonarscanner
# sudo chown -R sonarqube:sonarqube /opt/sonarscanner
# vi sonarscanner/conf/sonar-scanner.properties
    
    sonar.host.url=http://localhost:9000

-- Save & Quit (:wq)

# chmod +x sonarscanner/bin/sonar-scanner
# sudo ln -s /opt/sonarscanner/bin/sonar-scanner /usr/local/bin/sonar-scanner



Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog
Copyright © 2016 Kousik Chatterjee's Blog