-
Notifications
You must be signed in to change notification settings - Fork 0
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
d5264a1
commit 35720aa
Showing
1 changed file
with
74 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,74 @@ | ||
pipeline{ | ||
agent any | ||
tools{ | ||
jdk 'jdk17' | ||
nodejs 'node18' | ||
} | ||
environment { | ||
SCANNER_HOME=tool 'sonar-scanner' | ||
} | ||
stages { | ||
stage('Checkout from Git'){ | ||
steps{ | ||
git branch: 'main', url: 'https://github.com/tainguyenbp/learn-programming.git' | ||
} | ||
} | ||
stage('Install Dependencies') { | ||
steps { | ||
sh "npm install" | ||
} | ||
} | ||
stage("Sonarqube Analysis "){ | ||
steps{ | ||
withSonarQubeEnv('sonar-server') { | ||
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=uptime \ | ||
-Dsonar.projectKey=uptime ''' | ||
} | ||
} | ||
} | ||
stage("quality gate"){ | ||
steps { | ||
script { | ||
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token' | ||
} | ||
} | ||
} | ||
stage('OWASP FS SCAN') { | ||
steps { | ||
dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit', odcInstallation: 'DP-Check' | ||
dependencyCheckPublisher pattern: '**/dependency-check-report.xml' | ||
} | ||
} | ||
stage('TRIVY FS SCAN') { | ||
steps { | ||
sh "trivy fs . > trivyfs.json" | ||
} | ||
} | ||
stage("Docker Build & Push"){ | ||
steps{ | ||
script{ | ||
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ | ||
sh "docker build -t uptime ." | ||
sh "docker tag uptime sevenajay/uptime:latest " | ||
sh "docker push sevenajay/uptime:latest " | ||
} | ||
} | ||
} | ||
} | ||
stage("TRIVY"){ | ||
steps{ | ||
sh "trivy image sevenajay/uptime:latest > trivy.json" | ||
} | ||
} | ||
stage ("Remove container") { | ||
steps{ | ||
sh "docker stop uptime | true" | ||
sh "docker rm uptime | true" | ||
} | ||
} | ||
stage('Deploy to container'){ | ||
steps{ | ||
sh 'docker run -d --name chatbot -v /var/run/docker.sock:/var/run/docker.sock -p 3001:3001 sevenajay/uptime:latest' | ||
} | ||
} | ||
} |