Jenkins Integration with GIT Maven Sonarqube Nexus Tomcat || Continuous Integration and Deployment

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome to my Channel today we are going to discuss about cacd continuous integration continuous delivery using Jenkins so in this video we are going to cover Jenkins sonar Cube Nexus so whenever developers committed code into the GitHub using Jenkins it will pull the code and it will Bill and it will generate at the bar right and that where we are deploying to the Tomcat and once build is done we will do the sonar Cube analysis and we will deploy that war file into the Nexus then we will deploy into the Tomcat server so for this demo I am going to create a four ec2 instances one is for Jenkins another one is sonar Cube another one is Nexus another one is Tomcat server okay and I have created the four servers ec2 server and for time being I have opened all the security groups for this demo only so I have connected the servers Jenkins server Nexus server sonar Cube and Tomcat okay by default we will get username at the rate IP address right so to change that one I use the command called sudo hostname CTL set iPhone hostname and name of the server if you give right it will be give the username of this machine okay it will be change the terminal name the command is sudo hostname Serial Set iPhone hostname and Jenkins if you give Jenkins it will be Jenkins if you use sonar Cube it will be sonar to remember okay and I have installed the Java as well on this missions to install Java the command is apt-get install jdk 11 okay for Nexus I installed Java 8 okay remaining everything Java 11 only so let me install the Jenkins on these machines and we will get into the demo to install zenkins you just need to go jenkins.io official website downloads if you go with the oven to write our missions are Ubuntu missions so we will directly run these commands once it is added right the repository details you just need to show the app to get update iPhone y now it is updated now if you start installing app in app to get installed Jenkins it should be installed Jenkins so Jenkins we know Jenkins is running on port 8080 so I have already opened the security group port 8080 and once it is done right you just need to do sudo system CTL start Jenkins if you check the status right so Jenkins is up and running if you need to start the server even of system is rebooted you just need to do so you know systems ETL enable Jenkins okay it is fine now right so if you want to access the Jenkins you just need to select the IP public IP with the port 8080 so it will give you the path where initial password is available Wireless Jenkins and secrets initial password should be available just need to get that password cat Jenkins secrets initial admin CD you need to do and foreign [Music] Jenkins secrets if you do there is a initial admin password if you catch this one right so we will able to get that initial password Here now install suggested plugins on the same Mission we will install git and maven so if you check it version I think it is install git if you check my oven right it is not installed my one is not available even initial password name of that and email ID some email ID just say one continue save and finish now Jenkins is ready okay on the same Mission I am trying to install Apache maven so you just need to do install Apache memory so in official website on download you can do download Apache maven in this you will able to see that tar file here so you just need to copy that and copy link address I am installing this into opt CD opt W get now to enter this one the command is star iPhone xvf Apache May haven't done this yet now Target generated and removing the star file RM iPhone RF Apache open bin doctor and if you want to rename you can rename this Apache Maven 2 Maven 3.9 I'm just moving Apache maven 2. Maven 3.9 now if you check there is a maven sorry 3.9 more mbn it should be 3.9 it is 39 actually yeah now it is 3.9 if you check 3.8 now we need to set the path otherwise it will not work okay to set the path the command is export by default the maven should be running on bin so here all the maven executable files are there so we need to set the path to set the path the command is export path equal to dollar path colon thing there is two slices last bit if you check now mbn iPhone version it will be available okay to to set the path permanently you have to do it in bass RC for that one home directory base RC at the land if you press Ctrl shift G you will go to the last line and press here you can paste here I'm saving this file I am just restarting for that one source base RC the file name so it will be saved permanently okay now we have I haven't installed on this Mission and then the same Mission wherever the Jenkins is installed we have installed Jenkins and git as well now Jenkins installation is done now we will try to do all the installation one and we will try to create a integrate the cacd pipeline decrease and we will start now we will see the sonar Cube installation official web page only we will use sonar Cube downloads so this is the latest version of sonar grip download so if you wanted to old versions you just need to go I am installing sonar Cube 8. the current version is 9.8 it is released in December 22. so for time being I am using sonar Cube 9 8.9 so to download instead of download you just need to do double right click and copy the link address in the same sonar mission so please request it is Java and CD opt folder I am downloading that sonar keep zip file okay we need to unzip this one currently the zip file is downloaded so you just need to do unzip sonar Cube so it's saying unzip is not available you have to do sudo you have to get install unzip F1 y so now one ZIP is done you just need to do again unzips on our Cube it is unzipped now we will remove the jio file so if you want to rename the file you can rename the file sonar Cube to sonar 8.9 Arsenal Cube 8 okay and currently the sonar Cube it is installed by the root okay but to make that one we need to create sonar user and we will try to run that sonar Cube as a sonar user okay so to create user the command is user ad sonar pass WD username sonar it will ask you to the new password and giving the new password one two three it is updated successfully now we need to change the permissions for this owner okay ch1 iPhone r sonar user and sonar group for the file name sonar Cube it now if you check the permissions are changed to sonar user okay to check that user is presented or not just you need to do Etc pass WD the user is created so on a user here okay now CD into sonar Cube 8 once this is done you just need to go to bin now before that the sonar user we have to update it in the configuration cdconf there is on our properties owner dot properties in waysonar.sh not here there is a sonar dot is there is a run as sonar Cube let me go to bin in Linux so ours is Linux machine so you just need to do Linux LS7 l in sonar dot sh file V sona.sh here run as a user right so you just need to give the sonar user okay the username we have to provide the user is sonar okay just need to pick it and Save now you have to start the sonar Cube so just sonar slash start now sonar keep started if you check the status it is running fine okay the sonar is running on Port 9000 so you just need to take the public IP and with port number 9000 it will give you the initial admin the initial admin password for sonar is admin admin only username admin password also admin it will ask you to change the password you have to change the password admin I'm changing the new password and updated so this sonar cube is installed successfully we will see how to generate the token how to update it in Jenkins file in the next step now we will try to install the Nexus okay now in the Nexus the Java version is required eight in this one no in the official documentation download Nexus Sono type Nexus the downloads versions in OS is UNIX or Linux right we just need to copy this link address and CD opt icate downloading the tar file and untiring it so for that one star iPhone x v of Nexus so it is fine now it is downloaded successfully and let's say final I am removing this tar file when you enter it you will get two folders one is the sonar type work another one is in excess okay so even to run this on a Nexus one we need to create a Nexus user so that we will run the server as an access user okay and to create Nexus user the command is user add Nexus password Nexus and it will ask you to update the password it will updated the password successfully now we need to update it instead of root we will make it to the access user so for that one see it's shown changing the ownership permissions to the Nexus group also Nexus and Nexus type and the same Nexus work as well type Nexus work now if you check it changes the permissions or CD Nexus and we have to updated the username in nexus.rc file CD bin LS7 there is a nexus.rc file you have to updated this run as username just uncomment this one and you have to provide the username Nexus now you have to start the Nexus this Nexus start so Nexus is starting it's getting some warning no issue if you check that Nexus is running okay so Nexus is running fine you just need to open Nexus is running on default Port 8081 you just need to take the public IP and port 8081 Nexus is running fine yeah it is coming up and it will give you that initial admin password okay in this place our username is admin the password will be available in this location you can grab the password come in this location hope it is gonna work okay add green the password you will get it here if you do cat so the password is this one so it will ask you to the change the password you have to change the password so we are disabling Anonymous user Anonymous access finish okay so we have successfully installed an exercise as well now we have to install Apache Tomcat let's try to do that installing Tomcat download Apache Tomcat server so you will get here and this is the official page and you have to install power file you just need to copy this one link address and go to the server this is the Tomcat server and CD opt and W gate LS iPhone l so you just need to do enter this file tar hyphen xvf Apache zip file now if you do enter it will be generated now you just need to remove rma1 RF a positive get the zip file the tar file I am removing so if you wanted to rename the file you can rename the file you just need to do no Apache 11 Apache I'm sorry Apache Tomcat 92 you just need to do Tomcat name okay now this is done now we need to provide the permission so we just need to change the instead of root we have to give the default Ubuntu user okay or Tomcat user so if you do CD there is a default user called and less Ubuntu so we are giving the permissions to the Ubuntu so LS7 l otherwise you also can create a tomcat user and change the permissions but for time being I'm going with Ubuntu only ch1 F and r o one two Ubuntu and Tomcat name so I am running the Tomcat using Ubuntu user only so CD Tomcat f l s f and L and CD bin so here the startup dot access and shutdown dot as a all the scripts with executable permissions are there so you just need to do startup.sh Tomcat started so you just need to able to access the Tomcat you just need to do port 8080 Tomcat is running on port 8080 you just need to take the public IP with port 8080 the Apache is running fine okay now to access the server are many server apps okay you are getting 403 access denied error the server status everything okay you just need to comment uh this file content.xml so that you can able to see that and later we can able to add the user to make that you have to go to CD web apps CD opt there is a file called CD Tomcat foreign CD web apps manager there is a Content dot XML here there is a meta dot enf under meta dot INF there is a content.xml file you have to comment the values the value part is there right you have to comment that one so concept mode to comment in XML you have to use this one and you have to close here okay this is fine now save this is done okay now after that if you make any changes in the Tomcat you have to restart the server okay to restart the servers you just need to do shutdown.sh on the same path in the bin directory okay if you do CD opt Tomcat 9 bin here ls7n if you do it is shutdown Dot I have to run this shutdown.sh now Tomcat is stopped now you not able to access this one now again you have to start so instead of every time if you do comes to bin path and you need to do so you can create a soft link okay you can run it anywhere for time being we are coming to every time this bin opt term current bin folder and the typing start dot um TomCat we are creating the Sim link okay let me Create a Sim link Ln F1 yes and the path slash startup.sh so I am giving slash user slash bin start Tomcat so I can run it in anywhere the same way lni panels pasted here shutdown dot sh and slash USA slash bin shutdown Tom stop Tomcat any name you can give so it will created the Sim links Android users have been start Tomcat stop Tomcat if you check now right it will ask you the password but we haven't created the users the Tomcat for time being you can only check the status if you check the server status it will ask you the password and username we can create a user and we will update it the initial usernames and passwords should be available as it said right in the config there is a tomcat users.xml file you have to update it you have to go to that config folder and here there is a users.xml file is there you just need to create I just need to open and added the user informations so you have to comment this one or you have to select anything the role best so like this you manage your way manage the script okay it is clearly the mentioned the role name manager UI and password if you need to change the password Here like the password I am giving Tomcat and username role name is manager dot UI like this you just need to add individual manager GUI manager scripts okay and admin GUI like this you can add so it will be work if you wanted to one more role for admin UI just need to copy paste say admin GOI so you can add here admin GOI comma admin F1 GUI okay so as I said if you make any changes you have to stop Tomcat and stop Tomcat so that only it will be reflected the changes see I am into config folder now so I have stopped from here only now it is stop you have to start the Tomcat no Tomcat is started if we you just need to give username Tomcat password see you able to see the default applications if you check manager app so the default applications are up and running okay like this we have to install the Tomcat now all the tools are installed successfully now we will try to do the Integrations we will try to create a job and we will make the changes created new job and the pipeline name I'm giving cacd sample app and pipeline create pipeline so you just need to start the pipeline with the syntax pipeline if you need any tools okay we just need to update we have the maven tool install we have to configure that as well so the syntax is Pipeline and the stages and the stage all those things we have to write step by step if you have to run any the job in particular region you just need to provide the time being I am running agent any and now stages stage under stage I am giving the stage name like grid checkout check out the code steps okay you have to provide the URL get URL and the branch name okay so git URL the code is this is the Sam chinna app I'm just using http and Branch name is comma branch colon Main stages stage steps correct only let's check now build now it is it is able to check out the code from gitlab to here okay this is fine now we need to do build this project to build the maven project you have to configure the maven where is your Maven is available for that one you just need to go to manage Jenkins Global tool configuration here Maven is that right installation you just need to unselect the maven and you have to provide the maven versions okay so Maven where it is presently available do PWD so Maven is presently here opt maven I'm just using this path the home path of maven or you just need to remove bin okay till here fine and the name of the application you just need to do Maven 3.9 and apply save now go to the Jenkins shop and go to configure add one more stage change the stage name build maven application build build the maven anything okay and here I am using sh ambient clean install so here you have to update the tools in the tool section you have to provide the maven version okay Maven path Maven iPhone 3.9 so now if you try to do it will install at Maven package also you have to use it will generate at the or file a bill no console output you can build this successful here hiring dot VAR file is generated okay no from this part we have get the code and build the application it will generate the orbital now we need to do sonar analysis okay to integrate sonar analysis we have to add the plugin manage plugins you have to go to available session check for sonar sonar scan that is a sonar Cube scanner plugin you have to install this one install without restart it is done then you have to go to sonar Cube in my account security you have to generate a token okay so you can give any name Jenkins sonar token generate copy this okay and the name should be Jenkins owner token you have to remember this token and you have to configure this token in Jenkins credentials manage Jenkins manage credentials Global add credentials so here secret text okay and the secret name secrete is you have to copy the ID anyway we have copied right you just need to take and copy the ID to give the name Jenkins sonar token so you can give the description same Duncan sonar token now this step is done you just need to once this is done okay just need to go to the job and we have to add the sonar Cube server details as well okay and that is one more step we have to do configure system if you scroll down there is a sonar Cube server add sonar okay you have to provide the sonar clip server details like IP name configured you just need to remove this and the sonar Cube token and the name of that sonar you have to provide next one or Cube 8 we have installed right this is fine okay here we have updated server URL and name of the server and the token apply save now go to the job and configure now we have to add one more stage sonar give to add that stage how to select the pipeline syntax okay with just do as with the sonar Cube environment so you can select the sonar Cube token name and it is already there generate pipeline okay it will generate it with credentials and you have to write the block Ambience owner Collins owner okay with the sonar Cube environment with credentials I have to add that one sonar Cube analysis so I have that stage is ready let me copy paste that stage there is one more stage called generate sonar Cube analysis app okay and here I am giving the with its owner Cube environment the installation name sonar qubit and credentials ID thus Jenkins owner Cube token and it will be run ambient sonar colon sonar so apply and Save now bill now it will be generated on all Cube analysis report if it is success OK this build is done now if you go to the sonar Cube projects available to see adding maven web app okay so you're able to see that report if you have any vulnerabilities if you need to use sonar Cube okay how many bugs vulnerabilities and security asks what all those things will be available here okay now this job is done now we need to do we need whatever the war file it is generated right we have to upload it to the Nexus now we have already installed the Nexus so we just need to add the plugin so to add the plugins we have to go manage plugins available just check for Nexus artifactory this is the plugin as access artifact uploader install so it is installed successfully now you have to configure Nexus username and password in manage credentials so manage credentials and here add credentials username password you have to give Nexus username and password save Nexus credentials I'm adding Nexus credentials so once this is done you have to create a artifact create a repository in Nexus okay to create repository indexes you have to go to repository in the settings and create Maven to hosted Repository and you have to give any name and giving China uh the name of the repository so our artifact should be updated here and releases that should be fine and layout policy if you have strict or premises anything is fine in line this is okay blob store default deployment policy allow redeploy and create okay it is I'm just copying this one and typing here now we have to completed this step now you have to generated that stage so using Nexus upload artifactory okay you have to select xs3 protocol http and URL you have to give the URL Nexus uploader URL you have to provide means you have to give the IP that should be fine and credentials you have to select Nexus credentials and the group ID if you don't know the group ID you have to go to Applications in the form.xml you have to check group ID is in the Java home and version you have to give the version name of the version and Repository you have to provide only the repository name that is repository name Chennai app okay and you have to tell you have to select where is the artifactory available okay the artifactor name and version you have to give the artifact name should be hiring okay artifact ID and type VAR sify not required and the file where it is located you have to tell in Jenkins job in the tar file varval should be generated under Target folders okay you just need to if you have confusion you just need to go to the job and you have to check if you CD into the job the target under Target folder the wire file should be available if you do CD go to job console output see under Target their bar file should be available you have to use the same here or file 403 freeze reload I think yeah we have to do again with the Nexus now this one Nexus artifact upload Nexus 3 protocol HTTP URL you have to provide the IP address credentials Nexus group ID you have to give group ID version you have to provide the version name repository and you have to provide the repository name and artifact where is the artifact available you have to provide that effect ID entifact ID is hiring and type for classifier not required and file you have to provide the file name Target hiring.warfile under workspace and the target folder the hiring.war file is there so you have to provide and generate the syntax okay this is generated successfully now you have to use the stage so the same stage I have ready with me so I just copy paste and change the values so here upload VAR file to Nexus Nexus artifactory classifier non-trick artifact ID here the artifact ID should be hiring hiring.war R file and Nexus credentials I have the same group ID same and the Nexus URL I think this one eight zero eight one Nexus 3 protocol HTTP the repository name Dot app okay and the version you have to provide the version this is the version now the stage is ready just copy paste this stage the same however I have shown you right the same only but to make it readable I have to did the same thing here also artifact ID classifier file name type okay next credentials group ID artifact ID version protocol everything same only okay now go to the job configure and one more stage apply save now build now the time being we have added values manually so I think it is failing let's check what is the author fail to transfer repository version okay not allow transfer failed let copy paste this only not here here only configure in the steps complete steps remove this so to make it readable classify credentials group ID Lexus access version Repository and version Play Save bill now let's check what is the issue think failed again uploading War file downloading failed to retrieve remote meta data indent hiring snapshot now and could not transform it again okay okay now let's do one thing we will change the version here edit for time being I'm just editing this version and committed now let's try to build again build now I think we have to update the version as well sonar key plugin was more questionable that should be fine sonar Cube analysis is done will success artifact uploader meta information could not be transferred okay now I think replay just version you have to view 1.0 instead of snapshot run again it is failed console output thing it is not issue with some reply let me create the repository again Repository let me delete first this Repository delete repository we will create this with same name create repository Maven to hosted it's in iPhone up sort of release or snapshot anything fine you only allow read apply remaining fine China app now let's do try again configure we have to remove the version snapshot please same build now I think what is that or let me read clearly fail to deploy artifact could not transfer artifact Java hiring dot wall from to Chennai app oh it is Java home dot dot let me try what is the war file limit is created it should be hiring.org okay okay got it got it now hiring.org if you go to that configure job group ID that should be fine hiring.war type War and group ID should be the same only in Access HTTP protocol then what it is let me fix this error in offline now this build is getting success and the changes are in the form.xml the snapshot version doesn't allow 1.0 I change it to 0.1 that is mentioned in the logs and one more thing I made it in Jenkins file we forgot to update the port number 8080 the changes in the Jenkins file we have given the Nexus URL only the port number we haven't given so change this one and updated version 0.1 previously 1.0 snapshot is there it is there so I change it to 0.1 and the Repository if you go here I change it to the layout policy permissive previously extract is there and only allow read apply so previously we have selected I think snapshot version now made it to release version if you check that artifact browse the China artifact it is created the war file here okay now this is the change I made to make that upload Nexus stay successfully now we have to deploy this far file into the Tomcat the next stage is to make it apply the war file to the Tomcat from Jenkins to the Tomcat server you have to do shs agent plugin installed go to manage Jenkins manage plugins available shs agent you have to install this plugin without restart now you have to add the credentials means the Tomcat server credentials you have to add go to manage Jenkins manage credentials global add credentials so the Tomcat server details you how to add username with private key ID how to provide Tomcat credentials anything ID name should be anything description also same and username you have to provide Ubuntu and you have to directly paste the key add key so the key is available here just copy paste the Pim file create credentials are created and that key is added okay now you have to generate the pipeline okay shs if you type think refresh you will able to see that shs agent and it will give you pick that credentials and Tomcat credentials shs agent and you how to add the block what you need to do here laughs and I have that stage ready so let me copy paste the stage and I'll explain here what I did here so go to Tom job not managing games anyway it is done configure stay system now upload a deploying a bar file to the Tomcat server so when the steps shs is in term card credentials under Tomcat credentials I am running I am copying that in the Target folder we have hiring dot wire file right that I am copy pasted into the Tomcat server okay if you need to take the public IP and updated here the Tomcat server public IP under where we are updating that Ubuntu Tomcat server the name of the Tomcat if you go here PWD the Tomcat 9. okay so instead of Apache this one just remove cat name under web apps we are pasting the war file so if you paste this into the wire file so you just need to do again Ubuntu shs as I said if you make any changes you have to restart you have to stop and you have to start the Tomcat see now this is done so under shs is in strict key checking I'm saying no when you do shs it will give you the prompt you have to continue you have to accept or not yes or no so I am disabling that for that one stick to key saying no under Target folder the wire file we are copying once under where file the Ubuntu web apps we are keeping that power file so after that shutdown and shutdown Dot shs and start that assets that's all now apply save bill now so this is failing let's check what is there console output permissions denied strictly there is a space shutdown.sh line and so it is running successfully unpaid as such as permissions denied so we just need to make Tomcat permissions [Music] it is Ubuntu only let me go back and I am making the permissions troubles on permissions let me check Tomcat 9. 3D Tomcat there is a Catalina I think CH mode ch1 iPhone r or one two colon Ubuntu lsfnl ch1 iPhone r Ubuntu over to now it is done if you check it is fine change the status value ready Dash Dash CH4 triple seven Tomcat 9. now it is done see the Tomcat thing this is done CD bin and that should be fine now let's check one more time with the script replay is there any space is there or not Ubuntu hostname Tomcat let's check the IP ad public script yeah Ubuntu colon web apps SCP copying that one only shs shut down under search let's try to run one more time will know if you get that permission issue we have to check at a time running twice console output shed okay okay we haven't updated this Apache right okay got it if you go to the script I think our name should be Tomcat 9 right that is the reason it is failing it's my mistake only and the name of the server should be Tomcat 9 right it is looking yeah okay now it should be fine operative in it is looking for Tomcat 9 but it is Apache Tomcat 9.7 something it is there right but our name should be under Tomcat it should be Tomcat 9 bin okay so that is the reason it is failing no hope this time it will be success if you get errors if you read the errors and you can able to fix the issues I think one more time it is failed let's check what is that saying permissions denied Catalina out file you can't create Catalina dot or permissions okay okay but file is copied and it is saying while starting it's saying permissions limit okay okay locks let's check CD dash dash logs it having permissions so it is creating with root let's change the permissions for log folder so 3D logs CH mode rch1 will do ch1 iPhone R Ubuntu colon Ubuntu I am changing complete here invalid group name Ubuntu spelling mistake or if you check it is changed now and try to do one more time build thing it is going to be the root user for that logs that is the reason but Tomcat is running on Ubuntu user I think it is going to be fail or success I think it is Success now yeah finally we made it success now to check that one take the Tomcat IP ad public IP and port 8080 slash hiring oh sorry what is this let me take incognitive 404 server index.jsp file not found is it is this the build is Success the war file also done okay but to access application it's saying index.jsp file is not found let me go here 3DS RC it is available right let me update welcome to BC radio devops channel installed I just updated green commit okay is there a new issue with the web apps user and let me try to remove and under time being add the roles we will add let's see to fix this one now try to run try to build one more time foreign try to access the Tomcat port 8080 think 500 internal error okay okay having some issue let me debug this because I think the permissions are Catalina and let me go to this shutdown manually stop Tomcat Disturbed now it is shut down now start Tomcat Tomcat is started now fine if you go to manage apps there is a hiring app see it is able to access the application is able to access successfully now let's try to change here change that commit and try to trigger build so this time it should be pick automatically let me change check the configuration once again apply save now this is done will try to refresh and things there is some issue with after changing the permissions for the log it have some issues but if you do manually shut down start Top Market and start Tomcat see the changes is working fine the issue should be after changing the proper permissions for the Tomcat it have issue but the pipeline everything it is able to getting success okay so what I did is we have get the code from GitHub to Jenkins and we did the build the variable should be generated after that we generated the sonar Cube analysis report after that we have to push the war file to the Nexus then it is deployed into the Tomcat okay so so we did cacd continuous integration and continuous delivery the only the thing is I think after we made the changes of complete log it having that issue other than that everything is working fine okay if you like the video please share and subscribe thanks for watching bye
Info
Channel: BCReddy Devops
Views: 3,689
Rating: undefined out of 5
Keywords:
Id: BT5ZmZmQaIU
Channel Id: undefined
Length: 90min 17sec (5417 seconds)
Published: Tue Feb 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.