=============== Jenkins CI CD =============== 1) Build & Deployment process 2) Challenges with Manual build & deployment 3) Jenkins Introduction 4) Jenkins Setup 5) Jenkins CI CD Pipeline 6) Git + Maven + Docker + Jenkins ============================= What is Build & Deployment ============================= 1) Take latest source code from git hub repo 2) Compile Source Code 3) Execute Unit Test cases 4) Package our application (jar/war) 5) Build Docker image 6) Create Docker container ======================================== Challenges in Manual build & deployment ======================================== 1) Every day we need to deploy latest code 2) Deploy code in multiple environments Ex: DEV, SIT, UAT and PROD 3) Takes lot of time 4) Repeated Work 5) Error Prone => To overcome above challenges we need to automate project build and deployment process. ================== What is Jenkins ? ================== 1) Jenkins is free & open source software 2) Jenkins developed using Java language 3) Jenkins is used to automate Build & Deployment process 4) Using Jenkins we can implement CI CD => CI CD means continuous integration and continous deployment. =============== Jenkins Setup =============== https://github.com/ashokitschool/DevOps-Documents/blob/main/04-Jenkins-Docker-Project.md ====================== Jenkins Pipeline ====================== => Jenkins pipeline contains set of steps to automate project build and deployment process. => We can create jenkins pipeline in 2 ways 1) Declarative Pipeline 2) Scripted Pipeline (groovy) ===================================== Jenkins Declarative Pipeline Syntax ===================================== pipeline { agent any stages { stage('git clone'){ steps { // logic } } stage('mvn build'){ steps { // logic } } stage('build image'){ steps { // logic } } } } ============================================ Git + Maven + Docker + Jenkins Integration ============================================ ## Source Code Repo :: https://github.com/ashokitschool/maven-web-app => Create CI CD pipeline using jenkins with below stages Stage-1 : Git Clone Stage-2 : Maven Build Stage-3 : Build Docker Image Stage-4 : Deployment ================ Final CI CD Pipleline =========================== pipeline { agent any tools{ maven "Maven-3.9.9" } stages { stage('git clone') { steps { git 'https://github.com/ashokitschool/maven-web-app.git' } } stage('Mvn Build'){ steps{ sh 'mvn clean package' } } stage('Build Image'){ steps{ sh 'docker build -t ashokit/webapp .' } } stage('Deployment'){ steps{ sh 'docker run -d -p 9090:8080 --name ashokit ashokit/webapp' } } } } ==================== Real-Time workflow ==================== => DevOps team will setup Jenkins server in linux vm => DevOps team will manage users in jenkins server (role based access) => For Development team members, only jobs read & execute access will be available. => Development team will send request to DevOps team to create jenkins pipeline for the project. => Based on Dev Team request, DevOps team will create CI CD pipeline for the project. Note: If CI CD job execution got failed then we need to check job execution logs (console output).