How to integrate Sonarqube with Jenkins Part 1 #sonarqube #jenkins #aws #ec2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to my channel AWS devop litch 11 in this video we are going to see how to integrate sonar cube with genkins so in my last video I have talked about sonar Q I have explained about what is the use of sonar q and how it helps developers to analyze their codee identify the Bucks and correct their code accordingly so in this we will see how we can integrate Phar cube with genkins how to pull a project bya genkins compile it using Maven and send the source code to sonar Cube and sonar Cube will analyze the source code and publish the results so let us directly go ahead with the lab instructions meanwhile if at all you have not watched my previous video on how how to set up the sonar Cube you can click on the link above and you'll be able to watch my previous video so as part of this video we will set up sonar Cube as a first step and then we will go ahead and set up genins then we will do the integration between the two so as part of solar Cube setup I'm going to launch a t2. small instance in AWS because that is a minimum prerequisite for sonar Cube sonar Cube requires minimum of 2 GB of memory which is available only in the t2. small instance so let me first go ahead and launch the instance then we will have to install open jdk 11 so sonar Cube again being a Java based application I'm going to install the open jdk 11 then we are going to set up the sonar Cube Community Edition where I'm going to use the version 8.9.2 because the lat latest version 9. X version of the sonar Cube it is having some compatibility issues with genkins so 8.9.2 is considered to be a very stable version and it is also available for the the long-term support so I'm going to use 8.9.2 version of sonar Q now as part of the genkin setup I'm going to launch genkins or rather I'm going to launch a t2. micro instance and install genkins on this instance then again install open jdk 11 then we will go ahead and install genkins then we will be installing MAV and git because I'm going to use my project po source code is available in the GitHub repository and I'm going to use Maven to compile the code then as part of the maven and kit integration we also going to install the following plugins on the genkin server we are going to install MAV invoker an integration GitHub plug and as part of the sonar Cube integration we are also going to install sonar Cube scanner then we will have to configure the system in genkins and add the sonar Cube details into the genkin server then we will be setting up the sonar scanner 4.6.2 version again in the genkin global tool configuration then we will be creating a job which is going to pull the project from the GitHub and it is going to compile the project using Maven create artifacts and then send the source code to the sonar Cube server and solar Cube server is going to analyze the code and send us the reports so these are all the sequence of steps that we are going to follow so now let's directly get into the lab and let me start with the solar Cube setup so as a first step I'm going to launch the t2. small easy to instance I'm in the AWS ec2 console so let me launch an instance I will say sonar Q and with respect to the Ami I'm going to select the Amazon linux2 Ami and as I mentioned we are going to launch the t2. small e to instance so here in the instance type I'm going to select t2. small and let me select my one of my existing in keeper and with respect to the security group first I will open the SSH Port from my IP address and then later on once the instance is set up we can open the port 9,000 for sonar Q so while this instance is being launched let me also launch an instance for Jenkins I will name it as Jenkins again I will select the lx2 Ami instance type I will leave it as t2. micro and I will select the keypad let us launch this instance okay now the sonar Cube instance is up and running so as a first step what I will do is I'm going to open the port 9,000 as well because sonar Cube runs on the port 9,000 so let us go ahead and open this in the security group let me say edit inbound rules so I will add a custom TCP rule with Port 9,000 open from anywhere let me save this rules now let us log into the solar Cube server okay let me upload the keys so as a first step we need to install the Java open jdk level so let me just put my instructions first is install the open jdk Lev which is available from the Amazon Linux extras repository so I will say Amazon hyph Linux hyen extras install Java hyphen open jdk 11 okay so Java has been installed let me check the version of java I will say Java minus version can see here it is a open jdk version 11.0.2 so now let us go ahead and download the sonar Cube 8.9.2 Community Edition so it is available from this particular link so if I go to this link okay you can see here binaries dosar source.com and I click sonar Cube here and here you can see the all the versions of sonar Cube that is available so let me go ahead and select version 8.9.2 try this link okay so I'm just uh trying to download the solar Cube 8.9.2 Community Edition okay so it has been downloaded okay you can see here this is the binaries in the zip form so let me go ahead and unzip this package unzip okay so as a best practice let's go ahead and delete that the zip package I will say R minus F so we have downloaded the solar now as a Next Step let us go ahead and create a user for sonar Cube because we need a user called sonar admin in order to run this application so I will say user add sonar admin so let me set a password for this user password sonar admin okay so now the user sonar ad has been created now the next up what we need to do is we need to add this user to the de group so that it gets some permissions so for adding to the wheel group I will say vudo and let me search for V here and I'm I'm going to add an entry I will say sonar admin just copy this one similarly I'm going to make one more entry here below this line our Adit all equal to all and let me copy this as well no password p and space all that's it now let me save this file okay so the user has been added to the wheel group now what we will do we will go ahead and execute the sonar. EXs script in order to start the application so I'm already in the op directory it go to the solar Cube 8.9.2 directory and let me go into the P directory now I will go into our OS folder which is Linux x86 564 so here you can see there is a script sonar. I will say do/ sonar. space start so this is a command to start the application so it has started the sonar Cube application now I verify if the application has been started successfully is saying sonar cube is not running okay so we are getting this message because I am running the application as a root user okay so I'll have to switch user to sonar admin and then restart or start the sonar Cube application so what I will do is I'm going to switch user to sonar admin sudo Su minus sonar admin okay now I'll just verify if I am logged in as a sonar admin user yes so now let me try to start the sonar Cube application I will go to opt then here we'll go into the solar Cube 8.9.2 folder then let me go into the bin folder go to this Linux x86 64 now I will say/ sonar Dosh SP fail to start sonar Cube this is a message I'm getting okay that's because we are missing one step here so if I go into the opt directory you can see that you know the sonar Cube directory is still owned by the user root so I need to change the ownership to the sonar admin user so let me first do that I will exit I'll go back to the root prompt and let me give this command ch1 minus r sonar admins sonar admin and that particular folder so what I'm doing here is I'm giving the ownership to the folder sonar Cube hyphen 8.9.2 to the user sonar admin and the group is also sonar ad okay so this step is very important before we start the sonar Cube application as a sonar admin user let me see what is the exact folder name okay 9.2.4 6101 okay so let me copy this folder okay done now if I say LS minus L you can see that this particular directory is owned by the sonar admin user now let me switch to the sonar admin user and then I'll go back to the opt directory I'll go into this 8.9.2 then CD bin okay x864 now let me try to start the sonar Cube application sonar. space start okay now you can see here the start at sonar Cube we will verify if the application is running yeah now it is saying that it is running right we will try to access this application in the browser let me go to my ec2 dashboard I'll grab this IP address and as I told you before solar Cube runs on Port 9,000 so I will say this IP colon 9,000 so it is starting the application okay so solar cube is up and running all the systems are operational that's message we got okay so let us log in with the default username password it is admin anouncment okay and it will ask you to reset the password and change it to a new password let me enter the old password which is admin and I'm going to set it as a maybe admin 1 2 3 let me click update okay so you can see that our sonar Cube application is up and running this is our project screen so this is our first step where we have set up the sonar Cube so we are done with all these steps from the point of view of sonar Q right so we launched a t2. small instance we have installed the open jdk 11 and we also installed the sonar Cube verion 8.9.2 the community region right so now let us go ahead and set up genkins as our next step but before I do that what I wanted to do is for genkins we need an authentication key from sonar Cube I'm going to create that key and keep it ready so that we can use that while setting up the genkins so how to create that key let me go to Administration here and I will go to security I go to users and here under the tokens I will say add a token and I will give I give it a name this is a token for Jenkins right so I will say Jenkins and _ token this is for genkins to authenticate with sonar q and let me copy this and I'm going to paste it here and I will be using this later while we are configuring genkins now let me close close the screen okay so yeah we are done with the part one of this video wherein I just showed you the setup of the sonar Cube version 8.9.2 and we also have created an authentication key which we will configure in genkins so so the next part of this video I'm going to show you how to set up genkins and how to integrate it with sonar Cube so I'll meet you all in my next video thank you
Info
Channel: awsdevopsniche11
Views: 903
Rating: undefined out of 5
Keywords: aws, devops, sonarqube tutorial, sonarqube, join devops, sonarqube integration with jenkins, create ec2 instance in aws, aws ec2 tutorial, sonarqube installation linux, jenkins, jenkins ci cd pipeline, jenkins tutorial
Id: iu8JQQK6Fq8
Channel Id: undefined
Length: 20min 55sec (1255 seconds)
Published: Sat Sep 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.