Pages

Tuesday, October 18, 2016

Integrating Jenkins With Sonar Qube

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

Save the file along with your source directory.
 7. Configure the Jenkins – Job
 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

20 comments :

  1. 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.

    ReplyDelete
  2. Hi my family member! I want to say that this article is awesome, nice written and come with approximately all vital infos.
    I'd like to see more posts like this .

    ReplyDelete
  3. This design is spectacular! You obviously know how to keep a reader entertained.
    Between 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!

    ReplyDelete
  4. Thanks for tһе gоod writeup. It in reality was a amusement account іt.
    Looҝ advanced tօ far introduced agreeable from
    you! However, һow can we communicate?

    ReplyDelete
  5. This is the right blog for everyone who really
    wants 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!

    ReplyDelete
  6. Hello There. I discovered your blog the use of msn.
    That 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.

    ReplyDelete
  7. Không chỉ đốі với nữ giớі mà vùng kín củа nam сũng là khu ᴠựϲ rất nhạy cảm.
    Do đó 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ớі.

    ReplyDelete
  8. Thanks for sharing such a nice thinking, article is pleasant, thats why i have read it
    completely

    ReplyDelete
  9. Hi, i feel that i noticed you visited my weblog so i came to go back the
    prefer?.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!!

    ReplyDelete
  10. I loved as much as you'll receive carried out right here. The sketch is tasteful, your authored material
    stylish. 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.

    ReplyDelete
  11. I enjoy what you guys tend to be up too. This sort of clever work and
    exposure! Keep up the superb works guys I've
    included you guys to my own blogroll.

    ReplyDelete
  12. Hello, Neat post. There's an issue along with your website in web
    explorer, might check this? IE nonetheless is the market chief and a huge component of people will omit your
    magnificent writing because of this problem.

    ReplyDelete
  13. Hi,

    Even 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

    ReplyDelete
    Replies
    1. Iam sorry, all this time i never read comments and i started doing that now. Is the issue Solved?

      Delete
  14. Comment se déroule l'éducation sexuelle à l'école ?

    ReplyDelete
  15. Hurrah! Finally I got a weblog from where I be able to actually get valuable information regarding my
    study and knowledge.

    ReplyDelete
  16. Hi ,
    Do 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.

    ReplyDelete
  17. There's a beautiful аnd cathartic simplicity іn that.

    ReplyDelete
  18. What's up, just wanted to tell you, I loved this article.
    It was helpful. Keep on posting!

    ReplyDelete
  19. Hello to all, how is everything, I think every one is getting more from this web site, and your views
    are good in favor of new visitors.

    ReplyDelete