----->>>> 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 "
}
}
Comments
Post a Comment