From 48219e1b111f9a7b0d64f24fb7d01262307a11b6 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 2 May 2024 17:18:54 +0000 Subject: [PATCH 01/15] Dockerfile pushed --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4aec375 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Use a slim Node.js base image for building +FROM node:18-slim AS builder + +# Set working directory +WORKDIR /app + +# Copy package.json and other package management files +COPY package*.json ./ + +# Install dependencies (use RUN for development, COPY for production) +RUN npm install # For development builds + +# Optional: Copy your application code in a separate stage +FROM node:18-slim + +# Set working directory +WORKDIR /app + +# Copy your application code +COPY . . + +# Expose the port your application uses (replace 8080 with your actual port) +EXPOSE 3000 + +# Start the application (replace "start.js" with your entry point) +CMD [ "npm", "start" ] # Or "node start.js" + From 1389844628db3ac9bb065f046e55fe7313d8f9e3 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 2 May 2024 18:02:24 +0000 Subject: [PATCH 02/15] jenkins --- jenkinsfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 jenkinsfile diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 0000000..81cf985 --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,24 @@ +pipeline { + agent any + + tools{ + nodejs 'node18' + } + + stages { + stage('Checkout') { + steps { + // Check out the code from Git repository + git 'https://github.com/vamanrathod/node-express-server-rest-api' + } + } + + stage('Build and test') { + steps { + // Build your application artifact + sh 'npm install && npm startv' + } + } + + } +} From c9509dc3138d4df504e945988cd2a8490bc594d9 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Thu, 2 May 2024 23:35:35 +0530 Subject: [PATCH 03/15] Update jenkinsfile --- jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 81cf985..7d5dd26 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -16,7 +16,7 @@ pipeline { stage('Build and test') { steps { // Build your application artifact - sh 'npm install && npm startv' + sh 'npm install && npm start' } } From 3a2f5dd71153ba38488c8c88e6a50a1c65a7be45 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Fri, 3 May 2024 00:42:35 +0530 Subject: [PATCH 04/15] Update jenkinsfile --- jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jenkinsfile b/jenkinsfile index 7d5dd26..896d336 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -20,5 +20,17 @@ pipeline { } } + stage("Docker Build & Push"){ + steps{ + script{ + withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ + sh "docker build -t zomato ." + sh "docker tag zomato vamanrathod199/zomato:latest " + sh "docker push vamanrathod199/zomato:latest " + } + } + } + } + } } From f5ce67507540ae5a89f88050a154b97f4d2d8098 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Fri, 3 May 2024 00:44:23 +0530 Subject: [PATCH 05/15] Update jenkinsfile --- jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkinsfile b/jenkinsfile index 896d336..ec97993 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -13,10 +13,10 @@ pipeline { } } - stage('Build and test') { + stage('Dependencies') { steps { // Build your application artifact - sh 'npm install && npm start' + sh 'npm install' } } From 2294de2d796e1b9cd46374ac0c43cf5d9b21f32d Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Fri, 3 May 2024 02:16:40 +0530 Subject: [PATCH 06/15] Update jenkinsfile --- jenkinsfile | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/jenkinsfile b/jenkinsfile index ec97993..e336e7f 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -1,11 +1,21 @@ pipeline { agent any - tools{ + tools{ nodejs 'node18' } + environment { + SCANNER_HOME=tool 'sonar-scanner' + + stages { + stage('clean workspace'){ + steps{ + cleanWs() + } + } + stage('Checkout') { steps { // Check out the code from Git repository @@ -13,7 +23,24 @@ pipeline { } } - stage('Dependencies') { + + stage("Sonarqube Analysis "){ + steps{ + withSonarQubeEnv('sonar-server') { + sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=vivo \ + -Dsonar.projectKey=vivo ''' + } + } + } + stage("quality gate"){ + steps { + script { + waitForQualityGate abortPipeline: false, credentialsId: 'squ_aa89a6a07fbfba6bccdbe01d406fcbaef0c16729' + } + } + } + + stage('Install Dependencies') { steps { // Build your application artifact sh 'npm install' @@ -23,11 +50,11 @@ pipeline { stage("Docker Build & Push"){ steps{ script{ - withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ - sh "docker build -t zomato ." - sh "docker tag zomato vamanrathod199/zomato:latest " - sh "docker push vamanrathod199/zomato:latest " - } + withDockerRegistry(credentialsId: 'docker', toolName: 'docker', url: 'https://hub.docker.com/'){ + sh "docker build -t vivo ." + sh "docker tag vivo vamanrathod199/vivo:latest " + sh "docker push vamanrathod199/vivo:latest " + } } } } From 50673962085c852a225a8a2525735b79d53ee4b6 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Fri, 3 May 2024 02:21:41 +0530 Subject: [PATCH 07/15] Update jenkinsfile --- jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jenkinsfile b/jenkinsfile index e336e7f..5d6e777 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -7,7 +7,7 @@ pipeline { environment { SCANNER_HOME=tool 'sonar-scanner' - + } stages { stage('clean workspace'){ @@ -60,4 +60,5 @@ pipeline { } } -} +} + From e5bbaae71ce8a967ac95e284116d652ee8f0ac07 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 00:26:57 +0530 Subject: [PATCH 08/15] Update jenkinsfile --- jenkinsfile | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/jenkinsfile b/jenkinsfile index 5d6e777..4a41009 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -6,7 +6,7 @@ pipeline { } environment { - SCANNER_HOME=tool 'sonar-scanner' + SCANNER_HOME=tool 'sonarqube' } stages { @@ -19,26 +19,28 @@ pipeline { stage('Checkout') { steps { // Check out the code from Git repository - git 'https://github.com/vamanrathod/node-express-server-rest-api' - } + git credentialsId: 'github', url: 'https://github.com/deepikapwr/node-express-server-rest-api.git' + } } stage("Sonarqube Analysis "){ steps{ - withSonarQubeEnv('sonar-server') { - sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=vivo \ - -Dsonar.projectKey=vivo ''' + withSonarQubeEnv('sonarqube') { + sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=job \ + -Dsonar.projectKey=job ''' } } } stage("quality gate"){ - steps { - script { - waitForQualityGate abortPipeline: false, credentialsId: 'squ_aa89a6a07fbfba6bccdbe01d406fcbaef0c16729' + when { expression { params.action == 'create'}} + steps{ + script{ + def credentialsId = 'sonarqube' + qualityGate(credentialsId) } - } - } + } + } stage('Install Dependencies') { steps { @@ -50,10 +52,10 @@ pipeline { stage("Docker Build & Push"){ steps{ script{ - withDockerRegistry(credentialsId: 'docker', toolName: 'docker', url: 'https://hub.docker.com/'){ - sh "docker build -t vivo ." - sh "docker tag vivo vamanrathod199/vivo:latest " - sh "docker push vamanrathod199/vivo:latest " + withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){ + sh "docker build -t deepika ." + sh "docker tag deepika dpka531/deepika:latest " + sh "docker push dpka531/deepika:latest " } } } @@ -61,4 +63,3 @@ pipeline { } } - From dc83fce5c27725dfce5c86b87b1d8dc65b48d52b Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 00:29:08 +0530 Subject: [PATCH 09/15] Create compose.yaml --- compose.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 compose.yaml diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..c46231b --- /dev/null +++ b/compose.yaml @@ -0,0 +1,5 @@ +services: + redis: + image: 'dpka531/deepika:latest' + ports: + - '3000:3000' From 35ab9def8c0146efafb68197249ea920f76cc8c7 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 00:38:39 +0530 Subject: [PATCH 10/15] Update jenkinsfile --- jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jenkinsfile b/jenkinsfile index 4a41009..3a9c900 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -61,5 +61,11 @@ pipeline { } } + stage('Deploy (Optional)') { + steps { + sh 'docker compose up -d' + } + } + } } From 4f00aeca0480894ec510ee4975bfe04c3a66a23c Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 00:41:03 +0530 Subject: [PATCH 11/15] Update jenkinsfile --- jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 3a9c900..4b335e6 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -63,7 +63,7 @@ pipeline { stage('Deploy (Optional)') { steps { - sh 'docker compose up -d' + sh 'docker-compose up -d' } } From ec260de36a08c6cd5d9f0fa49713589adda2e1ef Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 00:58:30 +0530 Subject: [PATCH 12/15] Update jenkinsfile --- jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 4b335e6..0e4411e 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -63,7 +63,7 @@ pipeline { stage('Deploy (Optional)') { steps { - sh 'docker-compose up -d' + sh 'cd node-express-server-rest-api/compose.yaml && docker-compose up -d' } } From b784a76fbbfbafe0c7b8c87a964d29a680d1f437 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 01:05:01 +0530 Subject: [PATCH 13/15] Update jenkinsfile --- jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 0e4411e..55b664c 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -63,7 +63,7 @@ pipeline { stage('Deploy (Optional)') { steps { - sh 'cd node-express-server-rest-api/compose.yaml && docker-compose up -d' + sh 'cd compose.yaml && docker-compose up -d' } } From 02c68e5c2b6f2982cfdaaed626612007d4ee17e6 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 01:09:03 +0530 Subject: [PATCH 14/15] Update jenkinsfile --- jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 55b664c..4b335e6 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -63,7 +63,7 @@ pipeline { stage('Deploy (Optional)') { steps { - sh 'cd compose.yaml && docker-compose up -d' + sh 'docker-compose up -d' } } From 9de71d6bcb5e8200f63638902695fe5ac4e63694 Mon Sep 17 00:00:00 2001 From: vamanrathod <165011355+vamanrathod@users.noreply.github.com> Date: Sun, 5 May 2024 01:23:39 +0530 Subject: [PATCH 15/15] Update compose.yaml --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index c46231b..0831e71 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,4 +2,4 @@ services: redis: image: 'dpka531/deepika:latest' ports: - - '3000:3000' + - '4000:4000'