-
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.
Merge pull request #13 from tainguyenbp/feat/learning-jenkins-files
learning jenkins cicd with jenkinsfile
- Loading branch information
Showing
2 changed files
with
95 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,21 @@ | ||
pipeline { | ||
agent any | ||
|
||
stages { | ||
stage('Build') { | ||
steps { | ||
echo 'Building..' | ||
} | ||
} | ||
stage('Test') { | ||
steps { | ||
echo 'Testing..' | ||
} | ||
} | ||
stage('Deploy') { | ||
steps { | ||
echo 'Deploying....' | ||
} | ||
} | ||
} | ||
} |
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' | ||
} | ||
} | ||
} |