SonarQube Jenkins | How to Integrate SonarQube and Jenkins | Edureka

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi guys and welcome in today's session we are going to look at integrating jenkins and sonar cube and this can be used to manage your project but before we begin if you are new to this channel consider subscribing and turn on the notifications so you don't miss an update also if you are interested in the certification program check out the links below so let's begin by discussing today's topics these are what is sonarq what is jenkins prerequisite for the integration of sonar cube and jenkins then we will have a hands-on demo in which we will run a simple project by integrating these two so let's start so what is sonarqube well sonarcube is a open source platform made for continuous inspection of code quality this makes it possible for developers to improve the quality of their code and avoid vulnerabilities and bugs thus it helps maintain the code integrity and avoid bugs now let's see what is jenkins in devops continuous integration is important and this is achieved using jenkins which is an open source automation tool made for continuous integration and continuous delivery purposes it is easy to install and as a huge community of developers and this is one of the reason why it is so popular in devops community next we look at the prerequisites or steps for integrating jenkins with sonarqube here we have major requirement of having sonar cube and jenkins servers so after the first two conditions have been met we will generate a token for accessing the sonar cube next we will install so nut scanner plugin in jenkins and then configure jenkins in order to inspect our project which has been deployed on the github repository now with that let's move on to the demo first thing you must have is jenkins and sonar cube up and running now the first step for you to do is to create an access token which will be used by the jenkins to access sonar view so to do that first you create a new project in sonarqube and then select manually and give your project a name now give your token any name and then click generate now this is the token that will be used by jenkins to access tonight so what we'll do is we'll copy this and we'll save it now the next step is to add the credentials into the jenkins but before we do that we will install the plugin so we go over to manage jenkins and click on manage plugins in here we click on the available plugins and search for sonarcube so we see the first option sonar cube scanner and what we'll do is we'll install this without restart so now that the installation has been successful we'll click this button which will essentially restart jenkins and now that the jenkins is restarting all you need to do is wait till jenkins is ready now let's login to our jenkins now do you remember the token that we earlier created what we are going to do is we are going to add this into our jenkins credential so to do that we go to manage jenkins and click on manage credentials under security here we click on this and then we go to global credentials now we add our credentials and because we only have the token we are going to select the secret text here now we'll copy this value and then paste the token into the secret field here and we'll provide it a name we do the same for description and click ok now before we can do an other thing we need to configure the system so first we go here and then we will scroll down and click on the environment variable in here under sonar cube installation will click on add sonar cube and give it a name then we'll provide it with the value since we are running on the localhost 9000 port we'll use the same value here now we'll select the token that we previously fed into this and we will click save now we again go to manage jenkins and go to global tool configuration and here we will scroll down now under this setting which says sonar cube scanner will add now will provide it a name and then click save now we are ready to make our project but before we do that first i wanted to show you what i have here so this is the project that i have and in this what we have is a web file so in this we have some html files so here what we are going to do is we will add this project and build it using jenkins and then sonar cube will scan our code and tell us what is wrong if it is right so let's create our project here i'll select the freestyle project and here i'll provide the project a name now i'll click ok and i'll provide a description now i'll hit this portion here because i want to specify the number of days and the maximum number of belts that i want to keep now for our code what i'll do is i'll provide it with my code which has been stored here so i'll copy this and then clone it into my jenkins now because we have the main branch here we need to change this in our project as well so we will write main instead and here we will take this button which says prepare sonar cube scanner environment okay we'll select none for now and now we will add a build step and in here we will select invoke top level maven target now that we have this you have to have your maven path defined in your jenkins so we select this and for the goals i'll say clean install sonar colon sonar and essentially after saving this it should be able to run so we build our project and see what is the console output and as you can see here it says build has been successfully built and the analysis can be seen by going to this result so we open this link and here we can see what is the reliability of our code so in here we see that we can improve our code a little bit and when you click here you can see and identify what is problem with your code and if you click why is this an issue you will find what the non-compliant code looks like and what the compliant code should look like so if your code has any error you can refer to this and essentially make your code better and therefore you can make your code better by following the compliant codes which have been provided by the sonar scanner and now that you have seen how you can run a simple project using jenkins and sonarq you can also use a pipeline feel free to experiment and learn as you stumble into errors because errors are the only way that you can improve and with that the demo is concluded if you want to learn more about how to install jenkins check out our other videos thank you for watching this video i hope you have enjoyed listening to this video please be kind enough to like it and you can comment any of your doubts and queries and we will reply them at the earliest do look out for more videos in our playlist and subscribe to edureka channel to learn more happy learning you
Info
Channel: edureka!
Views: 24,647
Rating: undefined out of 5
Keywords: yt:cc=on, sonarqube jenkins pipeline, sonarqube integration with jenkins pipeline, how to integrate sonarqube with jenkins, sonarqube jenkins, jenkins sonarqube plugin, sonarqube jenkins tutorial, sonarqube integration with jenkins, configuring sonarqube in jenkins, sonarqube with jenkins, sonarqube jenkins pipeline example, devops training, devops tutorial, jenkins tutorial, devops edureka, edureka
Id: RyLTs5tVvns
Channel Id: undefined
Length: 9min 23sec (563 seconds)
Published: Thu Apr 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.