Setting up the Grails Project with SonarQube
Posted By : Hitesh Arora | 04-Mar-2015
Following are the steps to configure sonarqube for your grails project
1.Download SonarQube/Runner : Download the sonarqube as well as sonarrunner from :
2.Installation : Extract the .zip/.tar in your preferred location.In my case -
sonarQube is extracted at :
sonarRunner is extracted at :
3.Configure settings for sonarqube's database : Edit the sonar.properties to configure sonarQube's database. Execute the below command from terminal to access the sonar.properties :
then uncomment the following code (for mysql users) by removing # :
4.Create database : create database for sonarqube with name sonar
then create a new user :
here user has no permissions to do anything with the database until have the access.So provide the full permission on the sonar database
Here sonar.* is the access to sonar database and 'sonar' is the username in my case
5.Start sonarQube server : Now start sonarqube server using following command :
OS-ARCHITECTURE : OS you are using i.e in my case it is linux-x86-64..
6.Configuring sonar-runner : Edit sonar-runner.properties to connect to database(mysql in my case)
execute the command to open sonar-runner.properties :
then uncomment the following line by removing #
7.Configure grails-project : create sonar-project.properties at the root of your project
in my case it is ABC(project name) so it will be
and add the following configurations:
8.Final Step : Now start analyzing your project by running following command from the root of your project
here is my project directory :
then start the sonar-runner here by executing the command :
and then analyze your project by hitting the url :
NOTE:FOR GIT USERS,MAKE SURE THAT THERE SHOULD BE NO CONFLICT BEFORE EXECUTING SONAR-RUNNER OTHERWISE IT WILL THROW EXCEPTION SOMETHING LIKE
THANKS FOR YOUR TIME
1.Download SonarQube/Runner : Download the sonarqube as well as sonarrunner from :
http://www.sonarqube.org/downloads/
2.Installation : Extract the .zip/.tar in your preferred location.In my case -
sonarQube is extracted at :
/opt/sonarqube-5.0.1
/opt/sonar-runner-2.4
3.Configure settings for sonarqube's database : Edit the sonar.properties to configure sonarQube's database. Execute the below command from terminal to access the sonar.properties :
gedit /opt/sonarqube-5.0.1/conf/sonar.properties
#sonar.jdbc.username=sonar -->Line 1 #sonar.jdbc.password=sonar -->Line 2 #----- MySQL 5.x #sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar? useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
4.Create database : create database for sonarqube with name sonar
create database sonar;
create user 'provide-username that must be same as in Line 1 in previous step'@'localhost' identified by 'provide-password that must be same as in Line 2 in previous step';
GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'%' WITH GRANT OPTION;
5.Start sonarQube server : Now start sonarqube server using following command :
/opt/sonarqube-5.0.1/bin/OS-ARCHITECTURE/sonar.sh start
6.Configuring sonar-runner : Edit sonar-runner.properties to connect to database(mysql in my case)
execute the command to open sonar-runner.properties :
gedit /opt/sonar-runner-2.4/conf/sonar-runner.properties
#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
7.Configure grails-project : create sonar-project.properties at the root of your project
in my case it is ABC(project name) so it will be
/home/hitesh/ABC/sonar-project.properties
sonar.projectKey=my-project-name sonar.projectName=Work sonar.projectVersion=1.0 sonar.sources=grails-app sonar.language=grvy sonar.sourceEncoding=UTF-8
8.Final Step : Now start analyzing your project by running following command from the root of your project
here is my project directory :
cd /home/hitesh/ABC
/opt/sonar-runner-2.4/bin/sonar-runner
http://localhost:9000
NOTE:FOR GIT USERS,MAKE SURE THAT THERE SHOULD BE NO CONFLICT BEFORE EXECUTING SONAR-RUNNER OTHERWISE IT WILL THROW EXCEPTION SOMETHING LIKE
Caused by: Unable to blame file grails-app/conf/DataSource.groovy. No blame info at line 33. Is file commited?
THANKS FOR YOUR TIME
Request for Proposal
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Hitesh Arora
Hitesh is a bright engineer with experience in Core Java , Grails , Elastic Search , Angular JS .