SonarQube is popular static code analysis tool. It is Java based tool. Here are the steps for installing Sonarqube.
first you need to install a database as SonarQube uses database to store code quality report. We can use MySQL, Postgres, Oracle or MSSQL. Here are the steps for setting up SonarQube using MySQL database :
sudo yum update -y
sudo yum install wget -yMySQL installation steps:
sudo rpm -ivh mysql-community-release-el7-5. noarch.rpm
sudo yum install mysql-server -y
Start MySQL service
Start MySQL service
sudo systemctl start mysqld
Would you like to setup VALIDATE PASSWORD component?
type n
now set up password for root user
Remove anonymous users?
type y
for Disallow root login remotely?
type y
for Remove test database and access to it?
type y
for Reload privileges tables
type y
Setup Sonarqube user and password
mysql -u root -p
SHOW GLOBAL VARIABLES LIKE 'storage_engine';
CREATE DATABASE sonar;
GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'localhost';
now type exit to come out of MySQL.
Sonarqube web server installation steps:
Start with java installation.
sudo wget --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept- securebackup-cookie' 'http://download.oracle.com/ otn-pub/java/jdk/8u141-b15/ 336fa29ff2bb4ef291e347e091f7f4 a7/jdk-8u141-linux-x64.rpm'
cd /opt
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-6.7.6.zip
sudo yum install unzip -y
sudo unzip sonarqube-6.7.6.zip
sudo vi /opt/sonarqube/conf/sonar. properties
uncomment the below lines by removing #:
sonar.jdbc.username=sonar
sonar.jdbc.password=password
sonar.jdbc.url=jdbc:mysql:// localhost:3306/sonar? useUnicode=true& characterEncoding=utf8& rewriteBatchedStatements=true& useConfigs=maxPerformance
sonar.web.host=0.0.0.0
sonar.web.javaOpts=-Xmx512m -Xms256m -XX:+ HeapDumpOnOutOfMemoryError
sonar.ce.javaOpts=-Xmx512m -Xms256m -XX:+HeapDumpOnOutOfMemoryError
Run Sonarqube as sonar user
create a user called sonar by executing below command:
sudo useradd sonar
sudo chown -R sonar:sonar /opt/sonarqube
Edit the sonar.sh start script and change the #RUN_AS_USER to be RUN_AS_USER=sonar
sudo vi /opt/sonarqube/bin/linux-x86-64/sonar.sh
Change
RUN_AS_USER=sonar
Run Sonarqube as sonar user
create a user called sonar by executing below command:
sudo useradd sonar
sudo chown -R sonar:sonar /opt/sonarqube
Edit the sonar.sh start script and change the #RUN_AS_USER to be RUN_AS_USER=sonar
sudo vi /opt/sonarqube/bin/linux-x86-64/sonar.sh
Change
RUN_AS_USER=sonar
now start the server
sudo sh /opt/sonarqube/bin/linux-x86- 64/sonar.sh start
for any issues, look at logs at
tail -f /opt/sonarqube/logs/sonar.log
Verify by going to browser http://hostname:9000
A pretty detailed explanation, I'm grateful to you for sharing. Applying initially CSS; C# and PHP I wanted to go to testing the code with SonarQube
ReplyDeleteimmediately after installing Java itself. But some installation errors made me stuck up to clarify the circumstances and troubleshooting, but before I launch SonarQube, I made sure
that my machine is running JavaVirtual and that the Java tutorials https://explainjava.com/enable-java-chrome/ that serve me as the main source also stayed on the hard drive and are available for work. Next, following the recommendation, I paid attention to setting up the plugins, it seems like it worked well ...
1
ReplyDeletecurl: (7) Failed to connect to 127.0.0.1 port 9000: Connection refused any reason why? sonarqube is up and running
ReplyDeleteThank you for these steps
ReplyDelete