Skip to content

Commit

Permalink
Merge pull request #13 from tainguyenbp/feat/learning-jenkins-files
Browse files Browse the repository at this point in the history
learning jenkins cicd with jenkinsfile
  • Loading branch information
tainguyenbp authored Jul 6, 2024
2 parents 067ef34 + 35720aa commit e465ed7
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
21 changes: 21 additions & 0 deletions jenkins-pipeline-scripts/Jenkinsfile
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....'
}
}
}
}
74 changes: 74 additions & 0 deletions jenkins-pipeline-scripts/uptime-kuma/Jenkinsfile
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'
}
}
}

0 comments on commit e465ed7

Please sign in to comment.