SonarQube Series Part - 8 | Demo for Analyzing a Java Project from eclipse IDE on SonarQube Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone my name is Lata Verma and welcome back to my channel thank you brains it is part number eight of the sonar Cube series till now in this series you have seen what is sonar Cube how sonarlint is related to sonar Cube what is the version metrics and how to download and install sonar Cube setting the environment for sonar Cube and things to remember before analyzing your project onto sonar Cube server and today in this video you are going to see the complete in detail demonstration of uh sending a project from Eclipse IDE to the sonar Cube server to analyze it onto that server in this video I will be covering all the steps which are required to analyze a Java project from Eclipse IDE to sonar Cube server so be there till the end of this video without missing any step so as we have to see the demonstration of analyzing a Java project from Eclipse IDE to sonar Cube server so first of all I need to have a project in Eclipse IDE so I'm just opening my IDE foreign so guys you can see that we have some applications over here and let's say uh all the applications which we have here out of these I would like to analyze this particular uh application onto the sonar Cube server so to analyze this onto the sonar Cube server uh first of all the point is see this is my may run application so I have pom.xml file this is my Maven project and this is using jdk 1.7 so I need to change the library here so I'm just making it jdk17 and here in the pom.xml file I just need to add a dependency for sonar Cube scanner because I want this project to be scanned by sonar Cube so the dependency of sonar Cube server uh sonar Cube scanner I need to add over here so I'm going to add that dependency here this is the dependency and this is the latest version of this dependency okay you can search it on Maven uh Central repository and you will be getting that dependency first on our Cube scanner after adding this dependency over here this project is ready to be analyzed by the sonar Cube server but on to the sonar Cube server also we have to create a project so make sure that your sonalcube server is up and running here so guys over here you have to first of all create a project how can you create a project on Sonar Cube server you can just simply click on create project and we can click on manually here so I'm going to create this with name let's say rest API uh project analysis and this is the project key main branch name is Main and I'm going to set up this project here so guys now why I'm creating this project onto sonar Cube server because your local project which is on IDE will be analyzed under this particular project of sonar Cube so on to sonar Cube you must have a project under which your your Ides or your project is going to be analyzed so this project will have a sync with this sonar Cube project okay so now the project to analyze is not picked up from Jenkins GitHub bitbucket gitlab or from any of the devops it is going to be picked up from an IDE which is locally present so that's why this is the option which we are going to choose so I would like to get the project from the local machine now from the local machine I need to send this project to sonar Cube project right so this application should have access to that sonal Cube project not every project is allowed to be analyzed by a sonar Cube server which is actually having a login I mean the users are supposed to get logged in and then only they can access this particular according to the user who is logged in the projects would be accessible so right now uh this project is to be analyzed under this particular project of sonar Cube so this sonar Cube project must be accessible to this local project so that's why a token is going to be generated so here to generate that access token we just need to click on generate so you you can see the token name is this it is going to get expired in 30 days so to generate it I can click on generate and this is the token which will be used to access this sonar Cube project from the IDE okay now I'm keeping it somewhere I'm keeping it in this notepad file now after this guys you can see if I click on continue I'm getting an option that run analysis on your project so which kind of project it is whether it is a maven project Gradle project.net project of what so it's a maven project so I'll just click on Maven and see there you go you are seeing what a complete straightforward command to to send your project to this particular sonar Cube project okay so this is the command which can be used for that Maven project to access this project and under this project the maven project will get analyzed okay you can see the command is what mvn and the goal is what clean then verify and then sonar call and sonar guys sonar Colin sonar is the goal which is used to send your project from your IDE to the sonar Cube server so this is the goal which we can use after that you can see the label is hyphen D sonar dot project key the project key is the name of the project the host URL is this 9000 I mean on to this particular Port the application is running and the login is what see login is what the token this is the same token which was generated recently okay this is the same token we have so I can copy this particular command to actually access this sonar Cube project from the IDE so that we can send a project to analyte to get analyzed under that particular sonar Cube project okay okay after this I can simply copy this command and then it is done you can see now this project has been created right now there is nothing the Project's main branch is not analyzed yet okay there is one more important thing which I told you in my previous video that before analyzing your project onto the sonar Cube server you need to make sure that the permissions analysis permission are enabled on Sonar Cube server by default the project which you create on Sonar Cube server does not have permission to analyze any project under it so that's why we need to enable that permission and how we can do that we need to go to Administration okay and then you go to projects here we have projects management you can click on that and then the project which you have created in on Sonar Cube okay you can go to that and here you can see we have added permissions okay this particular project does not allow right now to analyze any project under it so I just want to change the permission so I need to go for edit permission over here you can see that for only sonar administrators this execution in analysis is allowed but for sonar users uh execute analysis permission is not enabled so I just need to check that so I want everything to be analyzed security hotspots administrator related issues everything so I'm just clicking these check boxes and this is the main point which you just need to uh take care of before analyzing any project under sonar Cube project if it is not enabled make sure that this is checked okay so in this way you can enable the analysis permission on Sonar Cube server for a particular project after doing this now we are ready to send this project Eclipse project on to this sonar Cube server under this project for analysis so how can I do that I can simply right click on this project then I can go for run as and then I can go for Maven build so here I need to write that write the goals okay for which goal I would like to build this project so you know that when I created this project I got a maven Command right I copied it over here so guys we are not using command prompt so as such this m mvn command is not supposed to be used so after this whatever we have I can simply copy and paste it okay so mvn can be removed these are the goals which we have to write to build this project this Maven project and after that this slash is for you know like new line we have so I can skip this slash here and then this I can write after this and then host okay so I can write this host here and then the login with the token right so you can see guys we have given all the details of our sonar Cube project here right so to this Eclipse project I have given the gold clean verify sonar colon sonar means we want to analyze this project from this local uh machine or from this IDE to the sonar Cube server and that so now Cube server has a project with name or with project key as rest API project analysis so now Cube server is running at this port number 9000 okay localhost 9000 is the host URL and the login how that will be logged in so this is the token which is provided here okay after this you can simply apply it and then run it it will take some time so we just need to keep a watch on it so you can see guys now the build is successful now this Maven project has been built successfully for the goals which we have mentioned right and the and the goals or rest of the things whatever we need to provide while building the maven project we got from the sonar Cube server itself when we created this project right at the time of token generation after generating the token we got this particular Maven command so accept that mvn mvn thing okay you can write rest of the things uh in the maven build over here and you can see the build is successful now you can simply go to your sonarclub server and you just need to refresh right and there you go guys see your project Eclipse project rest API with password encoding is now analyzed by the sonar Cube server and it is passing this quality gate the past thing which is written over here is basically telling that the quality gate the standard quality gate is passed by this project and you can see that this is the clean code metrics we have got okay duplications are 0.0 percent coverage is 0.0 percent code smell and hotspot review and vulnerability and bugs all the things as shown here in short if you would like to get the detailed Matrix of this analysis you can simply click on it and then you will be getting how many bugs are there what are the vulnerabilities security hotspots what is the technical depth everything the complete analysis you are getting here if if you click on vulnerability you can simply click on this and you can see these are the vulnerabilities we have but that is okay because ultimately the quality gate is passed okay and if you talk about the quality gate so you can see here it is passed and the quality Gates if I click on so see I'm getting sonar V this is the default quality gate of sonar Cube server and the parameters which are set under this quality gate are these they require coverage to be less than 80 percent I mean they require coverage to be greater than 80 percent so if it is less than 80 percent then the quality gate will not be passed okay so these are the parameters we have so these conditions are basically showing that if it goes less than 80 percent then the quality gate will be failed duplicated lines if they are greater than three percent then the quality rate will get failed so in this way you can see all the parameters of the default quality gate which is set for sonar queue okay and guys you can see now the project which I created right is now there with this name rest API with password encoding I created uh the project with name something like rest API something like analysis but now I'm not finding that project anymore here because that has been replaced by the name rest API with password encoding as uh this project this application was accessing that particular sonar Cube project right detail of which I provided in the goals in the goals over here okay so I provided the detail of my project rest API project analysis and everything so that's why now in place of uh you know getting that particular name I'm getting the name exactly same name of my Eclipse project over here okay so guys this is the complete demonstration of analyzing a Java project from Eclipse IDE onto the sonar Cube server okay so I'm just giving you the summary what we did we created a project over here generated the token after generating the token we got this particular command for me one project if it is your Gradle project you can choose the option of Gradle and then you will be getting the Gradle uh command over there and you can make use of that after getting this command you can simply go to your project in the IDE simply right click on that project go to run as then Maven build and then just copy paste that command okay make sure that mvn which is written in the starting is removed because we are not using command prompt we are using IDE so this mbn is not needed to be written and these slashes are supposed to be skipped so guys this is the complete demonstration of uh analyzing uh Java projects from Eclipse IDE onto so narcube server so guys this is the last part of the series and I hope that all the parts which we have covered in this series are comfortable to you if you have you have any kind of difficulty so just go through with that particular video once again understand it after that also if you face any kind of challenges so you can write me in the comment box I will be helping you out okay so guys in this Cube series what is the version Matrix how to download and install it setting the environment for sonar Cube and then things to remember while analyzing the project on Sonar Cube server and at last you have seen the complete demonstration of analyzing Java project from IIT Eclipse IDE to sonar Cube server okay so guys I hope that all the videos which are there in the series are comfortable to you if you found this series useful for you so please hit the like button and if you have not subscribed my channel till now so do subscribe it now so that you can get the notification for my upcoming knowledgeable videos and uh share it with your friends okay so thank you so much guys see you in the next video bye
Info
Channel: Techie Brainz
Views: 1,024
Rating: undefined out of 5
Keywords: Wondershare Filmora
Id: 5QWE3ikF7Zg
Channel Id: undefined
Length: 20min 13sec (1213 seconds)
Published: Wed Jul 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.