sonarqube-logo

Install & Configure SonarQube on Amazon Linux (AWS)

This article we will install and configure SonarQube on Amazon Linux. Before that, lets get to know little bit about SonarQube and its feature

SonarQube is an opensource tool for continuous inspection of code quality. It has features like..


  • Code Quality : Check overall health of code and more importantly highlight code related issues which makes it a create tool to check code quality.
  • Intelligent bugs detection : It provides code analyzers uses powerful path sensitive dataflow engines which can point mistakes like null deferences, logical errors, resource leanks 
  • Multi language : It has more than 20 code analyzers for different languages/platforms like C/C++, JavaScript, C#, Java, COBOL, PL/SQL, PHP, ABAP, VB.NET, Python, RPG, Flex, Objective-C, Swift, Web etc;
  • DevOps Integration : It can be integrated with CI/CD tools using webhooks and REST APIs.

All of these make it a good tool to have for developers, team leads etc to maintain code quality. Now lets start with the installation of SonarQube on Amazon Linux.

We will deploy SonarQube without any database directly intergrating it with Jenkins and Github.

Step 1 : Download and Install SonarQube

Ensure you have java environment variable set on your system, usually amazon linux has this already preconfigured with it but incase if your using any other distro then I would recommend to do this, you can find reference for the same here.

First add repo using below command

sudo wget -O /etc/yum.repos.d/sonar.repo http://downloads.sourceforge.net/project/sonar-pkg/rpm/sonar.repo

then install SonarQube by running :

sudo yum install sonar

you can start/stop sonar using : sudo service start/stop sonar

Once this is done, you should be able to access SonarQube dashboard via browser with http://<ipaddress>:9000

sonarqube-configuration

Step 2 : Install and start MySQL database (Optional)

sudo yum install mysqld

sudo service mysqld start

To configure root password for first time use below command : 

sudo mysql_secure_installation

MySQL installation is optional as it not required while integrating it with Jenkins and Git which is what we are trying to do in this series.


 

 

 


  • Andy

    I just tried this and keep running into the `File contains no section headers` error. Have you run into this problem? I looked at several posts on StackOverflow. All of them point to a syntax error in the `sonar.repo` file. The file is auto generated and I have no idea where a syntax error would be. Any ideas?

    • Bhargav Amin

      Umm I did not face this issue, if you could share screenshot, log and sonar.repo file with me I can look into it. Plus also let me know which linux flavour your using to do this and have you installed all the pre-req before starting installation?

      It might be case where your system might have a missing dependencies because of which it is not able run sonar. just try to run command : sudo yum groupinstall “Development Tools”

      Once installation is succeeded just try running it once again. if you still face the same issue send me above mentioned things at mail@bhargavamin.com