Skip to main content

End To End CI CD Pipeline Project | CI CD Pipeline

----->>>> This is  Start of CI pipeline ------->>>>

pipeline {
    agent any

        tools {
            jdk 'jdk 11'
            maven 'maven3'
        }

        environment {
            SCANNER_HOME= tool 'sonar-scanner'
        }

    stages {
        stage ('Git checkout') {
            steps {
                git branch: 'main', changelog: false, poll: false, url: 'https://github.com/jaiswaladi246/Webshop-app.git'

            }
        }

        stage ('Git Compile') {
            steps {
                sh "mvn clean compile"

            }
        }

        stage ('Sonarqube Analysis'){
            steps {
                sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsoner.url=http:\\13.126.10.25:9000 \
                -Dsoner-login=squ_3fhkdhfkdhkdshfklsdjhkdsfslkd07r753 \
                -Dsoner.projectname=shopping-cart \
                -Dsoner.java.binaries=. \
                -Dsoner.projectKey=shopping-cart '''

            }
        }

        stage ('OWASP SCAN') { // web App Scanner - https://www.zaproxy.org/
            steps {
                dependencyCheck additionalArguments: ' --scan ./', odcInstallation: 'DP'
                dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
            }
        }

        stage ('Build Application') {
            steps {
                sh "mvn clean install -DskipTests=true"
            }
        }

        stage ('Build & Push Docker Image') {
            steps {
                script{
                    withDockerRegistry(credentialsid: 'bfjklgjf-545dfd-fdfsdfsd-5fsdf56',toolname: 'docker') {
                        sh "docker build -t shopping-cart -f docker/Dockerfile."
                        sh "docker tag shopping:latest ramshakarji/shopping:latest"
                        sh "docker push ramshanakrji/shopping:latest"
                    }
                }
            }
        }

        stage ('Trigger CD Pipeline') {
            steps {
                build job: "CD Pipeline", wait: true
            }
        }

    }
}


<<<<--- This is END of CI pipeline <<<< ----


---------------- Create New  Job and Trigger it --------------------


start of CD Pipeline --->

pipeline {

agent any

stages {
   stage ('Docker Deploy To Container')
     steps {
        script {
          withDockerRegistry(CredentialsId: 'bfureur-kdjf-fdfsdf-fdfsd-553ffd', toolname: 'docker')
               {
              sh "docker run -d --name shopping-cart -p 8070:8070 ramshaji/shopping:latest "
              }
           }
       }
    }
}

<----End of CD Pipeline

 3 Security Pipelines : 

For use DEVSECOPS which compare to normal devops procedure.

Security Analysis Tools

Sonar qube for Performing Code Quality check and Code coverage.
OWASP Dependency check for find-out for your source code has any known vulnerabilities.
Once docker image is created,   Trivy helps for scanning docker image itself.

stage ('Trivy Docker Scan') {

  steps {
     sh "trivy image
 ramshanakrji/shopping:latest "
        }
    
  }

 

Direct to source of Data


Comments

Popular posts from this blog

AWS : EBS Operation: Volume Resizing

 https://www.udemy.com/course/ultimate-aws-certified-sysops-administrator-associate/learn/lecture/27513472#notes Extend a Linux file system after resizing a volume :  Click Here lsblk    64  df -h    65  lsblk    66  df -h    67  clear    68  lsblk    69  df -h    70  sudo growpart /dev/xvda1 1    71  sudo growpart /dev/xvda 1    72  lsblk    73  df -h    74  lsblk    75  df -t    76  df -h last  step : reboot instance from console, it will get reflect. 

Deleting Files more then 3 days with some file exceptions.

  [h895879@hd1mnxi02lx totalProducts]$ ls accessories.html                        handbags.html_1689660001  handbags.html_1690947001 accessories.html_1689672601             handbags.html_1689660901  handbags.html_1690947901 beauty.html                             handbags.html_1689661801  handbags.html_1690948801 beauty.html_1689672601                  handbags.html_1689662701  handbags.html_1690949701 build-your-own-jewelry.html             handbags.html_1689663601  handbags.html_1690950601 build-your-own-jewelry.html_1689672601  handbags.html_1689664501  handbags.html_1690951501 handbags.html                           handbags.html...