SonarQube (formerly
Sonar) is an open source platform for continuous inspection of code quality. In
this article we will see how we can integrate Sonar Qube in Jenkins. We will
also build sample application which will use the integrated sonar Qube to test
the code.
1.
Sonar Qube Installation
a. Download the Sonar Qube with version
5.6.3
b. Unzip the sonar Qube
c. Go to <Sonar
Qube>/bin/<OS-version>/
d. Run “sh sonar.sh console” command
e. Once the server is started, access the
server from http://localhost:9000/ ( if
you have a name to your system use that). This will be used in configuring the
sonar qube servers in jenkins
2.
Sonar Runner Installation
a. Download the Sonar-runner-2.4
b. Unzip the sonar runner
c. Don’t run the sonar-runner. This will be
started from Jenkins.
Sonar
Qube vs Sonar runner
SonarQube (formerly just
"Sonar") is a server-based system. Of course you can install it
on your local machine (the hardware requirements are minimal). But it is
a central server with a database.
Analyses are performed by
some Sonar "client" software, which could be the sonar
runner, the sonar ant task, the sonar Eclipse plugin etc. The analysis results
can be automatically uploaded to the server, where they can be accessed via the
sonar Web application.
Once the Sonar Qube and Sonar runner are
installed. We then need to install Sonar Plugin in the Jnekins
3.
Download Jenkins Plugin
a. Download the Sonar Qube plugin 2.4.4
from Manage Jenkins => Manage Plugins
4.
Configure the Jenkins – Sonar Qube Server
a. Configure System =>
Under the Sonar Qube Server as,
Enter the Name.
Server URL – the one that we tried to
access above when we started the Sonar qube
Save
Note – Make sure to check the “Enable
injection of sonarqube server configuration as build environment variables
5.
Configure the Jenkins – Sonar Qube Scanner
Under the Sonar Qube Scanner,
Choose a new Sonar Qube Scanner Installation
as,
Add the name and in the SONAR_RUNNER_HOME
and pass the location of the unzip sonar-runner path above.
NOTE – also create a environment variable
with SONAR_RUNNER_HOME variable with the location of the sonar-runner path
Save and Apply
6.
Configure the Jenkins – Sonar Qube Project Properties file.
Every project that we want to check needs a
sonar-project.properties file. The file can be a simple one by just passing the
src location path. Here is a sample of the that I have
cat
sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=javaee7-simple-sample
sonar.projectVersion=1.0
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=javaee7-simple-sample
sonar.projectVersion=1.0
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
Save the file along with your source
directory.
Once
the file is created, create a Job with the sonar qube as,
Check the “prepare SonarQube Scanner
Environment”
In the Add pre-build Step , Choose the
“Execute SonarQube Scanner”.
A new Item will be added and provide the
path of the project’s “sonar-project.properties” file path as above.
Save and Run the Build. We can see the
project Analysis at the sonar Qube Dashboard at http://localhost:9000/
That is all you need to do when configuring
a Sonar Qube with Jenkins. More to Come. Happy Learning J
Facing login problem with your account? Gmail Assistance Phone Number Canada 1-888-414-1732 is there for you help, call and get instant help.
ReplyDeleteHi my family member! I want to say that this article is awesome, nice written and come with approximately all vital infos.
ReplyDeleteI'd like to see more posts like this .
This design is spectacular! You obviously know how to keep a reader entertained.
ReplyDeleteBetween your wit and your videos, I was almost moved to start my own blog (well,
almost...HaHa!) Wonderful job. I really loved what you had to say, and more than that, how you presented it.
Too cool!
Thanks for tһе gоod writeup. It in reality was a amusement account іt.
ReplyDeleteLooҝ advanced tօ far introduced agreeable from
you! However, һow can we communicate?
This is the right blog for everyone who really
ReplyDeletewants to find out about this topic. You realize so much its almost
hard to argue with you (not that I personally will need to…HaHa).
You definitely put a fresh spin on a topic that's been written about for many years.
Great stuff, just wonderful!
Hello There. I discovered your blog the use of msn.
ReplyDeleteThat is an extremely smartly written article. I'll make
sure to bookmark it and return to learn morde of your helpful info.
Thanks for the post. I'll certainly comeback.
Không chỉ đốі với nữ giớі mà vùng kín củа nam сũng là khu ᴠựϲ rất nhạy cảm.
ReplyDeleteDo đó những đấng mày râu сần phảі hết ѕức cẩn trọng khi thấy dương vật có mùi hôi, ngứa,
hаy tiết ra Ԁịch bất thường. Dương vật
có mùi hôі, ngứа không chỉ gây ra sự
tự ti cho nam giới mà còn ɡây ra nhiều ảnh һưởng đến chất
lượng đờі sống tình ԁục, cũng như sức khỏe của nam
giớі.
Thanks for sharing such a nice thinking, article is pleasant, thats why i have read it
ReplyDeletecompletely
Hi, i feel that i noticed you visited my weblog so i came to go back the
ReplyDeleteprefer?.I'm trying to to find issues to improve my web site!I suppose its good enough
to make use of a few of your concepts!!
I loved as much as you'll receive carried out right here. The sketch is tasteful, your authored material
ReplyDeletestylish. nonetheless, you command get bought an impatience
over that you wish be delivering the following.
unwell unquestionably come more formerly again since exactly the same nearly very often inside case
you shield this increase.
I enjoy what you guys tend to be up too. This sort of clever work and
ReplyDeleteexposure! Keep up the superb works guys I've
included you guys to my own blogroll.
Hello, Neat post. There's an issue along with your website in web
ReplyDeleteexplorer, might check this? IE nonetheless is the market chief and a huge component of people will omit your
magnificent writing because of this problem.
Hi,
ReplyDeleteEven after giving correct SONAR_RUNNER_HOME, it's giving me error:
FATAL: SonarQube Scanner executable was not found for SonarScanner
Build step 'Execute SonarQube Scanner' marked build as failure
Can you please help me with this
Iam sorry, all this time i never read comments and i started doing that now. Is the issue Solved?
DeleteComment se déroule l'éducation sexuelle à l'école ?
ReplyDeleteHurrah! Finally I got a weblog from where I be able to actually get valuable information regarding my
ReplyDeletestudy and knowledge.
Hi ,
ReplyDeleteDo We have any REST API for Jenkins Sonar Plugin. Using That API I want to pass these parameter dynamically from a program, not do a static configuration from Jenkins.
There's a beautiful аnd cathartic simplicity іn that.
ReplyDeleteWhat's up, just wanted to tell you, I loved this article.
ReplyDeleteIt was helpful. Keep on posting!
Hello to all, how is everything, I think every one is getting more from this web site, and your views
ReplyDeleteare good in favor of new visitors.