Building A Ci CD Pipeline With Github Docker Sonarqube Jenkins Maven and Nexus

Download as pdf
Download as pdf
You are on page 1of 31
Open in app ” +> Get unlimited access to the best of Medium for less than $1/week. Become a member x Q search Mecium in\ : Building a CI/CD Pipeline with Github, Docker, SonarQube, Jenkins, Maven, and Nexus Fuzail Ahmed - Follow 8minread - May 14 © Listen (") Share ++ More. 1, Introduction to CI/CD Pipeline * What is a CI/CD pipeline? ACI/CD pipeline is a set of automated processes that are used to build, test, and deploy software applications. The pipeline is designed to streamline the process of software development by automating many of the repetitive tasks that are required to build, test, and deploy applications. ‘A typical CI/CD pipeline includes several stages, including code compilation, testing, and deployment. Each stage is designed to perform a specific task in the software development process, and each stage is connected to the next stage in the pipeline, creating a continuous flow of code from development to production. * Why do we need a CI/CD pipeline? ‘The primary reason for using a CI/CD pipeline is to increase the efficiency of the software development process. By automating many of the repetitive tasks that are required to build, test, and deploy applications, the pipeline can significantly reduce the time and effort required to deliver software to users. In addition to increasing efficiency, a CI/CD pipeline can also improve the quality of the software being developed. By automating testing and deployment, the pipeline can identify issues and errors early in the development process, allowing them to be addressed before they become significant problems. + What are the benefits of using a CI/CD pipeline? Increased efficiency: By automating many of the tasks required to build, test, and deploy applications, the pipeline can significantly reduce the time and effort required to deliver software to users. Improved quality: By automating testing and deployment, the pipeline can identify issues and errors early in the development process, allowing them to be addressed before they become significant problems. Faster time to market: By reducing the time required to develop and deploy software, the pipeline can help organizations get their products to market faster, giving them a competitive advantage. Better collaboration: By automating many of the repetitive tasks required in software development, the pipeline can free up developers to focus on more creative and innovative tasks, leading to better collaboration and teamwork. Continuous feedback: By providing continuous feedback on the development process, the pipeline can help organizations make better decisions about resource allocation and prioritize their development efforts. andgor4 Flow Diagram 2, Tools Used in the Project Github for version control Docker for containerization SonarQube for code analysis Jenkins for automation Maven for building projects Nexus for artifact management Step 1: Create EC2 Instance — (Instance -1) No. of Instance — 01 AMI — Ubuntu Server 20.04 LTS (HVM), SSD Volume Type Instance type — t2.medium Security group — ALL TCP 1 Arpteaton sn mae (Amazon Machi map) Step 2: Connect with terminal and login as “Ubuntu” user and switch to root user using “sudo su” command. Step 3: Installing — Git, Java-11, Jenkins, Docker, Maven Packages apt update # install git & docker apt install git docker.io -y # Once the installation is complete, you can start Jenkins using the followii service docker start # You can check the status of Docker using the following command: service docker status # install Maven ed /opt wget /dev/nult echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ https: //pkg.jenkins.io/debian-stable binary/ | sudo tee \ Jetc/apt/sources. List.d/jenkins.list > /dev/nult sudo apt-get update sudo apt-get install jenkins Jenkins -version # Once the installation is complete, you can start Jenkins using the followi! systemctl start jenkins # You can check the status of Jenkins using the following command: sudo systenctl status jenkins + By default, Jenkins runs on port 8080. You can access Jenkins by opening your web browser and entering the URL http: //:8080 . Unlock Jenkins Your-Server-IP:8080 |__ Step 4: Configure Jenkins + When you first access Jenkins, you will be prompted to unlock Jenkins, To do this, you need to retrieve the initial administrator password from the Jenkins server using the following command: are Dy] * Copy the password and paste it into the “Administrator password” field on the Jenkins login screen. * Once you have unlocked Jenkins, you will be prompted to install recommended plugins. You can either install the recommended plugins or select the plugins that you want to install manually. rr ro Coeur add > 2 Jenkins Dashboard * Open Jenkins and navigate to “Manage Jenkins” > “Plugin Manager” > “available Plugins” > “Search — Maven Integration” > “Install without restart”. oe Plugins otters 2 me wee Seca Paes tet .—~ hipped bg teri dns Rds aneinertn SAORI pera apnangoanitia a otnacrigestn oe saa he * Open Jenkins and navigate to “Manage Jenkins” > “Global Tool Configuration”. * Scroll down to the “Maven” section and click on the “Add Maven” button. * Click on the “Save” button to save the Maven configuration. wo one * Open Jenkins and navigate to “Manage Jenkins” > “Credential” > “System” > “Global Credential (unrestricted)” Step 5: Configure SonarQube: * Click on the “Create” button to save the configuration. aS ‘SonarQube Pre-Requisités ——— ———— 5.1.Required 3 GB RAM CreateEE2 Instance for SonarQube — (Instance -2) New credentials * No.of Instance — 01 * Ami "Ubuntu Server 20.04 LTS (HVM), SSD Volume Type « Instance type — t2.medium « Security-group— ALL TCP) ° + Appesten an 9s tmape Amosee Matinee we Connect with terminal and login as “Ubuntu” user and switch to root user using “sudo su” command. 5.2.Java is Required apt update apt search openjdk apt install openjdk-11-jdk-headless java -version 5.3.Database is required Create Subnet groups with all availability zones sonar-sub Create RDS e . Go to the Amazon RDS dashboard. R . Choose the appropriate region for your instance. we . Click on the “Create database” button. > manne vs x ‘create database Engine Type — MySQL = Templates — Free tier Change DB Name a enguation : OSpoeceat one Create username and password ° Existing VPC SG — ALL TCP * Review and confirm your settings, then click on the “Create database” button to create your RDS instance. 5.4.Database users and permission is required apt update apt install mysql-server mysql -h sonar-db.cfmucsduutge.ap-south-1.rds.amazonaws.com -P 3306 -u admin CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER sonar@locathost IDENTIFIED BY ‘sonar’; CREATE USER sonar@'%' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO sonar@localhost; GRANT ALL ON sonar.* TO sonar@'%! ; quit 5.5. SonarQube two configuration file H 4 inst cd /opt H wget https: //binaries. sonarsource.com/Distribution/sonarqube/sonarqube-6. unzip sonarqube-6.7.6.2ip cd /opt/sonarqube-6.7.6/conf vi sonar.properties (Uncomment the highlighted lines) & add username and password, add rds endpoint instead of localhost (Uncomment the highlighted lines) sudo update-alternatives eee vi wrapper. conf wrapper. java.conmand=/usr/Lib/jvm/java-11-openjdk-amd6li/bin/jav: paste the java path Perse trerte ee epee Prugeiteot ier mee total 149 Cees Tr tee drwxr-xr-x ra 2018 drwxr-xr-x rr Prone} De eeecand Beye mY 2018 che Seite ig poe wees SSE as Wee 5 7.6/bin/Linux-x86-6ut | (we need to change the files permission from root to ubuntu in the path /bin/linux-x86-64) chown -R ubuntu:ubuntu /opt/sonarqube-6.7.6 Pech es pee Cea eres: mn Ey ts total 140 (bathe ae tamed Porat arg 20 2018 idrwxr-xr-x Patria’ 20 2018 idrwxr-xr-7 Pha thal’ 20 2018 melt ees aed ubuntu ubuntu 15. ply Re bas pa tessa Pointy 2018 wrapper* cet ase WL Aen ee cot a rao rs yr Rociaeery pe Sereeae mr cera rnc 20 Parrett cae rst sara Fr) Bair rata 20 Sir tm eT ee ean Vae Pecctmeec ere R Zy sot ee aL AE ttcs fom stet cae? exit Pita iee Path etree ec See er ees overt er reas Pearse pisrrevct (Exit to the Ubuntu user and change directory to sonarqube bin path and start the /sonar.sh) -/sonar.sh start % ./sonar.sh status * You can access SonarQube by opening your web browser and entering the URL http: // tar -xvf [email protected] (webpage ur: https://help.sonatype.com/repomanager3/product-information/download) «/sonar.sh start % ./sonar.sh status ee eee eee Pers etree d Pointe era eee eet See ees root @ip-172-31-33-133. : o-018 fed bin Pres eat Esmeceseey 31-33-133 frtctnrtamerererennresacocaroneretenveenierers Piru eeser eects trie iyiinycaerererensponereresrrenerennecevetsnrsareceveracerenrceniiters pense fore Fuster ser y earned eee tT] * You can access Nexus by opening your web browser and entering the URL http: // New Item > Pipeline > ok Configure = ome ° = - Jenkinfiles * Save your Pipeline & Build Now Prpenne U1 Cu Project Sonarube Quality Gate on Permalinks VFPUF: Sonar Qube eS OUTPUT: Nexus chmod 777 /var/run/docker.sock * Build Now cues nave + Q seoren 22 BU. | | ourpuT: JENKINS- C1/CD Pipeline (using Blueocean) OUTPUT: Final Application Output CI-CD Pipeline project using docker,jenkins sonarqube,maven,nexus ritten by Fuzail Anmed 2 Followers. IWS DevOps server-ip:8080/newapp More from Fuzail Ahmed 2 poor @ Fuzait Anmes CI/CD Pipeline: Jenkins Pipeline for Java Application with Maven, @ Fuzail Armes Create and Host a Wordpress Website on AWS EC2 with your own domain name Step 1: Launch an instance Amin read » Jun 14 Sa Q W hallenge for the #TerraWeek Monday Introduction to Terraform @ FuzzitAnmes Day 1— Introduction to Terraform * Infrastructure as Code (laC) 6minread © Jun? ay @ Fuzait anes Day 2 - Terraform Configuration Language (HCL) HCL (HashiCorp Configuration Language) is a declarative language used in Terraform to define infrastructure configurations. It provides a. 8minread » Jun? Hr ¢ Won See all from Fuzail Anmed. Recommended from Medium @ Fuzail Armes Create and Host a Wordpress Website on AWS EC2 with your own domain name Step 1: Launch an instance Amin read » Jun 14 Ha Q Ee > lenaens > Fonentstrnde ry for 015924985 1efa747¢ (jenkins-sarver i. ov 1B ee 1925.24 7p sor ‘eorpaeamssonaerem opener 1B oconaraeattee et ews meet re ETO 5 & Kishan Madhesiya Jenkins CI/CD pipeline with GitHub for Deploying React Docker application on EC2 instance. Project 1: Creating an EC2 instance (Ubuntu) ‘Tminread + Aug? je Qi [io Lists Staff Picks 422 stories - 248 saves Stories to Help You Level-Up at Work 19stories - 194 saves Self-Improvement 101 20stories » 483 saves Productivity 101 20stories - 473 saves Peer per Loa @ Aman Pathak in Devops.dev Deployed Java application using Maven, Sonarqube, Jfrog Artifactor, Jenkins, ArgoCD and finally... How to build, test, Code Analysis, Upload build Artifacts, build docker Image, Push docker Image and Deploy the Java-based Application? Qminread - May 19 Amazon RDS MySQL DataBase Amazon EKS (— ea B&B & ri oO 9 B cumhur Mesut Akkaya Working with Microservices-14: Creating Amazon RDS MySQL database for Kubernetes cluster in the... We continue our Production Pipeline. In this section, we will use Amazon RDS instead of MySQL pod and service during the Production stage... ‘Tminread - Aug 16 ema. management .azure. com/schemas/2019-04-@1/dep G@ tia anaparthy Azure ARM Templates: A Beginner’s Guide to Infrastructure Deployment Unlock the Potential of ARM Templates— Introduction and Template Structure Explained Qminread - Jun28 Docker Host Launche Jenkins Slaveragent Container ns Controller Container a eae Pipelines/jobs Containers @ Yassine Essadraoui Jenkins: Docker in Docker In this article 'm going to demonstrate how to install/run Jenkins controller and slave fully on Docker 4minread - Aug 13 ( ‘See more recommendations

You might also like