Skip to content

mukundDeo9325/Project-InsureMe1

Repository files navigation

$$\color{red} \textbf{Project} \ \ \textbf{InsureMe}$$

InsureMe was having trouble managing their software because it was all one big piece.
As they grew bigger, it became even harder to manage.

$\color{orange} \textbf{Requirements}$

1. Automated Deployment:

Whenever a developer makes changes to the code and pushes them to the main branch of the Git repository,
Jenkins should automatically start a deployment process.

2. CI/CD Pipeline:

Jenkins should:

  • Check out the latest code from the main branch.
  • Compile and test the code to ensure it works correctly
  • Package the application into a container using Docker.
  • Deploy the containerized application

With DevOps Approch I used several devops tools such as

  • Git: Managed code changes with version control.
  • Jenkins: Automated integration, testing, and deployment processes.
  • Docker: Containerized applications for consistency and scalability.
  • AWS: Provided infrastructure for hosting and deploying the application.
    Together, these tools streamlined development, testing, and deployment, ensuring efficient management of the InsureMe project.

$\color{orange} \textbf{Project} \ \textbf{Summary}$

  • Create EC2 instance on Amazon Web Services (AWS)
  • These servers will host application and manage its deployment.
  • Install Jenkins server to automate the process of building, testing, and deploying application.
  • Set up Jenkins to watch your code repository on GitHub.
  • Whenever someone makes changes to the code and pushes them to GitHub, Jenkins automatically kicks off a process to update and deploy application.
  • Used Docker to package application and its dependencies into a container, making it easy to deploy and run anywhere.
  • After that write a pipeline in Jenkins to build, test, and deploy your application automatically.
  • This pipeline runs every time someone makes changes to the code, ensuring that the latest version of your application is always available.
  • Whenever someone pushes changes to the code, Jenkins pulls the latest code, builds the application, creates a Docker image, and pushes it to DockerHub (a service for storing Docker images).
  • Then, it deploys the updated application
  • With this setup, you can fully automated process for building, testing, and deploying your application.
  • Whenever someone make changes to the code, Jenkins takes care of the rest, ensuring that your application is always up-to-date and running smoothly on your servers.

Project Steps

Launch ubuntu instance(t2.medium)

install jenkins

sudo apt update
sudo apt install fontconfig openjdk-21-jre  -y
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc]" \
  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins -y

install docker

sudo apt install docker.io -y
sudo systemctl start docker
sudo usermod -aG docker jenkins
sudo usermod -aG docker ubuntu
newgrp docker
sudo chmod 777 /var/run/docker.sock

SonarQube

docker run -d --name sonar -p 9000:9000 sonarqube:lts-community

install maven

sudo apt install maven -y

aws cli

sudo apt install unzip -y
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

install below plugins

stage view
maven integration
sonarqube scanner
aws credentials
s3 publisher
docker

configure tools in Manage Jenkins-> Tools

project project

add credentials

project project project

Click on Dashboard and create new project and select project type as pipeline project

setup webhook

project project

pipeline {
    agent any 
    tools{
        maven 'maven'
    }
    environment {
     SCANNER_HOME = tool 'sonar-scanner'
     S3_BUCKET = "project-insure-me-build-artifacts-store-oncdecb36"
     REGION = "ap-southeast-1"
     warFile = "target/Insurance-0.0.1-SNAPSHOT.jar"
     }
    stages {
        stage('code-pull'){
            steps{
                checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/mukundDeo9325/Project-InsureMe1.git']])
            }
        }
        stage('code-build'){
            steps{
                sh 'mvn clean package'
            }
        }
        
        stage("code-test") {
            steps {
                withSonarQubeEnv('sonar-server') {
                    sh '''
                        $SCANNER_HOME/bin/sonar-scanner \
                        -Dsonar.projectKey=InsureMe \
                        -Dsonar.projectName=InsureMe \
                        -Dsonar.sources=src \
                        -Dsonar.java.binaries=target/classes
                    '''
                }
            }
        }

        stage("code-test-quality gate") {
            steps {
                script {
                    waitForQualityGate abortPipeline: false, credentialsId: 'sonar-token'
                }
            }
        }
        stage('code-push'){
            steps{
                withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws-cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
                   sh 'aws s3 cp ${warFile} s3://${S3_BUCKET}/Artifacts/ --region ${REGION}'
                 }
            }
        }
       stage('docker-image'){
            steps{
                sh 'docker build -t mukunddeo9325/insuremeB .'
                
            }
        }
        
        stage('image-push'){
            steps {
       	       withCredentials([usernamePassword(credentialsId: 'docker-cred', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
            	sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword}"
                sh 'docker push mukunddeo9325/insuremeB'
               }
            }
        } 
        
        stage('code-deploy'){
            steps{
                sh 'docker run -itd --name insure-me -p 8089:8081 mukunddeo9325/insuremeB'
            }
        }
    }
}

without dockerhub

pipeline {
    agent any 

    tools {
        maven 'maven-3'
    }

   environment {
     S3_BUCKET = "project-insure-me-build-artifacts-store"
     REGION = "ap-south-1"
     warFile = "target/Insurance-0.0.1-SNAPSHOT.jar"
   }


stages{
    stage('code-pull'){
        steps{
            checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/mukundDeo9325/Project-InsureMe1.git']])
        }
    }

    stage('code-build'){
        steps{
            sh 'mvn clean package'
        }
    }
    
    stage('push-to-s3'){
        steps{
            withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws_cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
               sh 'aws s3 cp ${warFile} s3://${S3_BUCKET}/Backup/ --region ${REGION}'
             }
        }
    }
     stage('docker-image'){
        steps{
            sh 'docker build -t insure-me .'
        }
    }
    stage('code-deploy'){
        steps{
            sh 'docker run -itd --name insure-me -p 8089:8081 insure-me '
        }
    }
 }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors