forked from Aj7Ay/Hotstar-Clone
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24ebc88
commit 631137a
Showing
1 changed file
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
|
||
pipeline{ | ||
agent any | ||
tools{ | ||
jdk 'jdk17' | ||
nodejs 'node19' | ||
} | ||
environment { | ||
SCANNER_HOME=tool 'sonar-scanner' | ||
} | ||
stages { | ||
stage('clean workspace'){ | ||
steps{ | ||
cleanWs() | ||
} | ||
} | ||
stage('Checkout from Git'){ | ||
steps{ | ||
git branch: 'main', url: 'https://github.com/prashantsuk/Myntra-Clone.git' | ||
} | ||
} | ||
stage("Sonarqube Analysis "){ | ||
steps{ | ||
withSonarQubeEnv('sonar-server') { | ||
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=myntra \ | ||
-Dsonar.projectKey=myntra''' | ||
} | ||
} | ||
} | ||
stage("quality gate"){ | ||
steps { | ||
script { | ||
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token' | ||
} | ||
} | ||
} | ||
stage('Install Dependencies') { | ||
steps { | ||
sh "npm install" | ||
} | ||
} | ||
stage('OWASP FS SCAN') { | ||
steps { | ||
//dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit', odcInstallation: 'DP-Check' | ||
// dependencyCheckPublisher pattern: '**/dependency-check-report.xml' | ||
sh 'pwd' | ||
} | ||
} | ||
stage('Docker Scout FS') { | ||
steps { | ||
script{ | ||
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ | ||
//sh 'docker-scout quickview fs://.' | ||
//sh 'docker-scout cves fs://.' | ||
sh 'docker --version' | ||
} | ||
} | ||
} | ||
} | ||
stage("Docker Build & Push"){ | ||
steps{ | ||
script{ | ||
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ | ||
sh "docker build -t myntra ." | ||
sh "docker tag myntra prashant680844/myntra:latest " | ||
sh "docker push prashant680844/myntra:latest" | ||
} | ||
} | ||
} | ||
} | ||
stage('Docker Scout Image') { | ||
steps { | ||
script{ | ||
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ | ||
sh 'docker-scout quickview prashant680844/myntra:latest' | ||
sh 'docker-scout cves prashant680844/myntra:latest' | ||
sh 'docker-scout recommendations prashant680844/myntra:latest' | ||
} | ||
} | ||
} | ||
} | ||
stage('TRIVY FS SCAN') { | ||
steps { | ||
script{ | ||
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ | ||
// sh 'docker-scout quickview prashant680844/myntra:latest' | ||
//sh 'docker-scout cves prashant680844/myntra:latest' | ||
//sh 'docker-scout recommendations prashant680844/myntra:latest' | ||
|
||
sh 'trivy image prashant680844/myntra:latest > trivyfs.json' | ||
} | ||
} | ||
|
||
} | ||
} | ||
stage("Remove container"){ | ||
steps{ | ||
sh "docker stop myntra | true" | ||
sh "docker rm myntra | true" | ||
} | ||
} | ||
stage("deploy_docker"){ | ||
steps{ | ||
sh "docker run -d --name myntra -p 3000:3000 prashant680844/myntra:latest" | ||
} | ||
} | ||
stage('Deploy to kubernets'){ | ||
steps{ | ||
script{ | ||
dir('K8S') { | ||
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s', namespace: '', restrictKubeConfigAccess: false, serverUrl: '') { | ||
sh 'kubectl apply -f deployment.yml' | ||
sh 'kubectl apply -f service.yml' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |