From 69d771ff8dcb9b3dc51db8c142696618a6ae6001 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:06:38 +0530 Subject: [PATCH 01/24] Update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index aa8d86d..b18b120 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + From d4656726d40bb8e795ab08553410ace172fc6cb7 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:07:41 +0530 Subject: [PATCH 02/24] Update pom.xml --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index b18b120..aa8d86d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,3 @@ - From 8c717c9212a4d5afef692d99903fe7090cc5a6e1 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Tue, 16 Jul 2024 09:46:09 +0530 Subject: [PATCH 03/24] Update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index aa8d86d..b18b120 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + From 5e0b2e1e310e09bc2a2aaa20e93eef903254b14b Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Tue, 16 Jul 2024 09:54:01 +0530 Subject: [PATCH 04/24] Update pom.xml --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index b18b120..aa8d86d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,3 @@ - From 5dc130e6396489878eae932201686ff0ee12708a Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:53:39 +0530 Subject: [PATCH 05/24] Update Jenkinsfile --- Jenkinsfile | 88 ++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 76 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7eca275..76f774c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,92 +1,28 @@ pipeline { - agent { - label 'maven-build-agent' - } + agent any tools { // Install the Maven version configured as "M3" and add it to the path. - maven "Maven3.9.5" + maven "Maven3.9.8" } stages { - stage('Checkout') { - steps { - checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/keyspaceits/javawebapp.git']]) - } - } + stage('checkout'){ + steps{ + git 'https://github.com/keyspaceits/javawebapp.git' + } + } + stage('Build') { steps { - // Run Maven on a Unix agent. - sh 'mvn clean install -f pom.xml' - - // To run Maven on a Windows agent, use - // bat "mvn -Dmaven.test.failure.ignore=true clean package" - } - - post { - // If Maven was able to run the tests, even if some of the test - // failed, record the test results and archive the jar file. - success { - slackSend channel: '#operations', message: 'Javaweb app build success', teamDomain: 'ksops', tokenCredentialId: 'slack', username: 'ksops' - } - - failure { - slackSend channel: '#operations', message: 'Javaweb app build has failed', teamDomain: 'ksops', tokenCredentialId: 'slack', username: 'ksops' - } - } - - - - } - stage ('CodeQulity') { - steps{ - withSonarQubeEnv('SonarQube') { - sh 'mvn clean install -f pom.xml sonar:sonar' - } - } - } - - stage ('NexusUpload') { - steps { - nexusArtifactUploader artifacts: [[artifactId: 'CounterWebApp', classifier: '', file: '/home/jenkins/workspace/javawebapp-declarative-pipeline/target/CounterWebApp.war', type: 'war']], credentialsId: 'NexusCred', groupId: 'com.mkyong', nexusUrl: '52.2.21.21:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-snapshots', version: '1.0-SNAPSHOT' - } - - } - stage("Stage deploy") { - steps { - deploy adapters: [tomcat9(credentialsId: 'tomcat-server', path: '', url: 'http://34.226.163.28:8080')], contextPath: null, war: '**/*.war' - } - } - stage('Stage apprl for Prod') { - steps { - echo "taking approval from Dev Manager" - timeout(time: 7, unit: 'DAYS') { - input message: 'Do you want to proceed to QA?', submitter:'admin' - } + sh "mvn -Dmaven.test.failure.ignore=true clean package" } } - stage('Deploy to Prod') { - steps { - deploy adapters: [tomcat9(credentialsId: 'tomcat-server', path: '', url: 'http://34.226.163.28:8080/')], contextPath: null, war: '**/*.war' - } - - post { - // If Maven was able to run the tests, even if some of the test - // failed, record the test results and archive the jar file. - success { - slackSend channel: '#operations', message: 'Javaweb app deployment success', teamDomain: 'ksops', tokenCredentialId: 'slack', username: 'ksops' + stage('deploy to prod') { + steps { + deploy adapters: [tomcat9(credentialsId: 'tomcat-server', path: '', url: 'http://172.31.91.56:8080/')], contextPath: null, war: '**/*.war' } - - failure { - slackSend channel: '#operations', message: 'Javaweb app deployment has failed', teamDomain: 'ksops', tokenCredentialId: 'slack', username: 'ksops' - } - } - - - } - - } } From 54e67a6713ca660c8c156cc623bc5e0705de0683 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:55:54 +0530 Subject: [PATCH 06/24] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 76f774c..47124ed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { stages { stage('checkout'){ steps{ - git 'https://github.com/keyspaceits/javawebapp.git' + checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/keyspaceits/javawebapp.git']]) } } From f0b8208adbcc7d1b0f75e493205b4471ca034b02 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:41:48 +0530 Subject: [PATCH 07/24] Update Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 47124ed..a1dbc33 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,6 +19,11 @@ pipeline { sh "mvn -Dmaven.test.failure.ignore=true clean package" } } + stage('upload artfacts tonecus'){ + steps{ + nexusArtifactUploader artifacts: [[artifactId: 'CounterWebApp', classifier: '', file: '/var/lib/jenkins/workspace/scripted-pipeline/target/CounterWebApp.war', type: 'WAR']], credentialsId: 'nexus', groupId: 'com.mkyong', nexusUrl: '172.31.9.61:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-snapshots', version: '1.0-SNAPSHOT' + } + } stage('deploy to prod') { steps { deploy adapters: [tomcat9(credentialsId: 'tomcat-server', path: '', url: 'http://172.31.91.56:8080/')], contextPath: null, war: '**/*.war' From 8110ba40a813942d5f5ccea3fd8022368c6fd027 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:42:59 +0530 Subject: [PATCH 08/24] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a1dbc33..a0d54ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { } stage('upload artfacts tonecus'){ steps{ - nexusArtifactUploader artifacts: [[artifactId: 'CounterWebApp', classifier: '', file: '/var/lib/jenkins/workspace/scripted-pipeline/target/CounterWebApp.war', type: 'WAR']], credentialsId: 'nexus', groupId: 'com.mkyong', nexusUrl: '172.31.9.61:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-snapshots', version: '1.0-SNAPSHOT' + nexusArtifactUploader artifacts: [[artifactId: 'CounterWebApp', classifier: '', file: '/var/lib/jenkins/workspace/declarative-pipeline/target/CounterWebApp.war', type: 'WAR']], credentialsId: 'nexus', groupId: 'com.mkyong', nexusUrl: '172.31.9.61:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-snapshots', version: '1.0-SNAPSHOT' } } stage('deploy to prod') { From ff2abacdf09e4920ef8fb1cd5ffbe15a2fa08b4c Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Sat, 20 Jul 2024 10:29:29 +0530 Subject: [PATCH 09/24] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa8d86d..dfe2360 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ CounterWebApp Maven Webapp http://maven.apache.org - 1.7 + 1.8 4.1.1.RELEASE 1.2 4.11 From e1ef06ed1b2b9d65490459ad43ae06d02cdb9fc8 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 07:30:48 +0530 Subject: [PATCH 10/24] Create deploy.yml --- .github/workflows/deploy.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7c9f764 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,50 @@ +name: Build and Deploy Java Project + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '11' + + - name: Build with Maven + run: mvn clean package + + - name: Upload WAR file as artifact + uses: actions/upload-artifact@v3 + with: + name: my-app-war + path: target/*.war + + deploy: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Download WAR file artifact + uses: actions/download-artifact@v3 + with: + name: my-app-war + path: ./deploy + + - name: Deploy to Tomcat + run: | + curl --upload-file ./deploy/*.war "http://:/manager/text/deploy?path=/myapp&update=true" \ + --user "TOMCAT_USER:TOMCAT_PASSWORD" + env: + TOMCAT_SERVER_URL: ${{ secrets.TOMCAT_SERVER_URL }} + TOMCAT_PORT: ${{ secrets.TOMCAT_PORT }} + TOMCAT_USER: ${{ secrets.TOMCAT_USER }} + TOMCAT_PASSWORD: ${{ secrets.TOMCAT_PASSWORD }} From 825c9e0c0456548a3fa0b4687e9bd24b5cfef9c6 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 07:32:07 +0530 Subject: [PATCH 11/24] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7c9f764..ffd580c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Build and Deploy Java Project on: push: branches: - - main + - master jobs: build: From 80baab0e64bfa141e46a28fa2751cba73827b8ab Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 07:40:06 +0530 Subject: [PATCH 12/24] Update deploy.yml --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ffd580c..1f901fb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -41,8 +41,7 @@ jobs: - name: Deploy to Tomcat run: | - curl --upload-file ./deploy/*.war "http://:/manager/text/deploy?path=/myapp&update=true" \ - --user "TOMCAT_USER:TOMCAT_PASSWORD" + curl --upload-file ./deploy/*.war "http://${{ secrets.TOMCAT_SERVER_URL }}:${{ secrets.TOMCAT_PORT }}/manager/text/deploy?path=/myapp&update=true" --user "${{ secrets.TOMCAT_USER }}:${{ secrets.TOMCAT_PASSWORD }}" env: TOMCAT_SERVER_URL: ${{ secrets.TOMCAT_SERVER_URL }} TOMCAT_PORT: ${{ secrets.TOMCAT_PORT }} From e0db653b4e6bac6a1b744fafcd41f324bb972be8 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:35:46 +0530 Subject: [PATCH 13/24] Update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index dfe2360..40e1366 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + From 99815c0fe06a554bb1d25c746b827c0229f3380f Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:26:45 +0530 Subject: [PATCH 14/24] Create Dockerfile --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6d8334c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM: tomcat:9.0 +COPY target/*.war /usr/local/tomcat/webapps From 1df4d4ab65c8092dbfadd3c9845a5287f5330c17 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:36:45 +0530 Subject: [PATCH 15/24] Update deploy.yml --- .github/workflows/deploy.yml | 71 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1f901fb..ee7d7ee 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,49 +1,48 @@ -name: Build and Deploy Java Project - +--- +name: cicd workflow to create docker image and upload image into DockerHub on: push: branches: - master - jobs: build: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: '11' - - - name: Build with Maven - run: mvn clean package - - - name: Upload WAR file as artifact - uses: actions/upload-artifact@v3 - with: - name: my-app-war - path: target/*.war - + - uses: actions/checkout@v3 + - name: Setup JDK 17 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: "17" + - name: Build with Maven + run: mvn clean install + - name: Login to DockerHUB + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push docker image + env: + IMAGE_TAG: ${{ github.sha }} + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:${IMAGE_TAG} . + - name: Push docker image + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:${IMAGE_TAG} deploy: runs-on: ubuntu-latest needs: build - steps: - - name: Download WAR file artifact - uses: actions/download-artifact@v3 - with: - name: my-app-war - path: ./deploy + - name: SSH to Docker Host and Deploy Container + uses: appleboy/ssh-action@v0.1.8 + with: + host: ${{ secrets.DOCKER_HOST }} + username: ${{ secrets.SSH_USERNAME }} + password: ${{secrets.SSH_PASSWORD }} + script: > + sudo docker pull ${{ secrets.DOCKERHUB_USERNAME + }}/mydimages:${IMAGE_TAG}" + + sudo docker stop myjavaapp || true + + docker rm myjavaapp || true - - name: Deploy to Tomcat - run: | - curl --upload-file ./deploy/*.war "http://${{ secrets.TOMCAT_SERVER_URL }}:${{ secrets.TOMCAT_PORT }}/manager/text/deploy?path=/myapp&update=true" --user "${{ secrets.TOMCAT_USER }}:${{ secrets.TOMCAT_PASSWORD }}" - env: - TOMCAT_SERVER_URL: ${{ secrets.TOMCAT_SERVER_URL }} - TOMCAT_PORT: ${{ secrets.TOMCAT_PORT }} - TOMCAT_USER: ${{ secrets.TOMCAT_USER }} - TOMCAT_PASSWORD: ${{ secrets.TOMCAT_PASSWORD }} + docker run -d --name myjavaapp -p8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:${IMAGE_TAG} From 08d50e48220920e211aae2a5284e70a15cbd2c64 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:39:07 +0530 Subject: [PATCH 16/24] Update deploy.yml --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ee7d7ee..c7c7c04 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,11 +9,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Setup JDK 17 + - name: Setup JDK 11 uses: actions/setup-java@v2 with: distribution: adopt - java-version: "17" + java-version: "11" - name: Build with Maven run: mvn clean install - name: Login to DockerHUB From fac35f56ab50f8506ac0242328d96bc28d118390 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:44:55 +0530 Subject: [PATCH 17/24] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6d8334c..7a55e7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ -FROM: tomcat:9.0 +FROM tomcat:9.0 COPY target/*.war /usr/local/tomcat/webapps From 55388603a5fc38cf27f49aa0d1f04ef25df66e53 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:54:33 +0530 Subject: [PATCH 18/24] Update deploy.yml --- .github/workflows/deploy.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c7c7c04..23344db 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,9 +24,9 @@ jobs: - name: Build and push docker image env: IMAGE_TAG: ${{ github.sha }} - run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:${IMAGE_TAG} . + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:latest . - name: Push docker image - run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:${IMAGE_TAG} + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:latest deploy: runs-on: ubuntu-latest needs: build @@ -38,11 +38,10 @@ jobs: username: ${{ secrets.SSH_USERNAME }} password: ${{secrets.SSH_PASSWORD }} script: > - sudo docker pull ${{ secrets.DOCKERHUB_USERNAME - }}/mydimages:${IMAGE_TAG}" + sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:latest sudo docker stop myjavaapp || true docker rm myjavaapp || true - docker run -d --name myjavaapp -p8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:${IMAGE_TAG} + docker run -d --name myjavaapp -p8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:latest From f70e14b7e76393570a20219f41639635ed81e271 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:56:45 +0530 Subject: [PATCH 19/24] Update deploy.yml --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 23344db..b1c58ef 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,6 +42,6 @@ jobs: sudo docker stop myjavaapp || true - docker rm myjavaapp || true + sudo docker rm myjavaapp || true - docker run -d --name myjavaapp -p8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:latest + sudo docker run -d --name myjavaapp -p8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/mydimages:latest From d308df5c9b746c8e4350091ab9281cd0e67b4ab0 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Thu, 23 Jan 2025 08:16:58 +0530 Subject: [PATCH 20/24] Update pom.xml --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40e1366..dfe2360 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,3 @@ - From a06613f5246e4009d1d83aa03823691cd6995fd1 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Sat, 5 Jul 2025 09:53:32 +0530 Subject: [PATCH 21/24] Update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index dfe2360..40e1366 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + From 2b955413812e986515f809b559eae33051c978ea Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Sat, 5 Jul 2025 10:01:41 +0530 Subject: [PATCH 22/24] Update pom.xml --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40e1366..dfe2360 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,3 @@ - From 0024021917f2830485e74f19ce00ff093c95654c Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Sat, 12 Jul 2025 08:51:19 +0530 Subject: [PATCH 23/24] Update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index dfe2360..40e1366 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + From 3c76e3789b1fa6877388f24cabb62cfcad37cd48 Mon Sep 17 00:00:00 2001 From: Keyspace It Solutions <52453809+keyspaceits@users.noreply.github.com> Date: Sat, 12 Jul 2025 11:00:37 +0530 Subject: [PATCH 24/24] Update Jenkinsfile --- Jenkinsfile | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a0d54ca..9997adc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,33 +1,56 @@ pipeline { agent any - tools { // Install the Maven version configured as "M3" and add it to the path. - maven "Maven3.9.8" + maven "Maven3.910" } stages { stage('checkout'){ steps{ - checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/keyspaceits/javawebapp.git']]) + git 'https://github.com/keyspaceits/javawebapp.git' } } - - stage('Build') { + stage('Build') { steps { - // Run Maven on a Unix agent. - sh "mvn -Dmaven.test.failure.ignore=true clean package" + script { + try { + sh "mvn -Dmaven.test.failure.ignore=true clean package" + slackSend(channel: 'ci-cd-alerts', color: 'good', message: "Build Success! Job Name: ${env.JOB_NAME} Build Num: ${env.BUILD_NUMBER} (${env.BUILD_URL})", teamDomain: 'keyspaceitsgroup', tokenCredentialId: 'slackcred', username: 'suresh') + } catch (Exception e) { + slackSend(channel: 'ci-cd-alerts', color: 'danger', message: "Build Failed! Job Name: ${env.JOB_NAME} Build Num: ${env.BUILD_NUMBER} (${env.BUILD_URL})", teamDomain: 'keyspaceitsgroup', tokenCredentialId: 'slackcred', username: 'suresh') + error 'Build failed' + } + } + } + } + stage ('CodeQulity') { + steps{ + withSonarQubeEnv('SonarQubeServer') { + sh 'mvn clean install -f pom.xml sonar:sonar' + } } } - stage('upload artfacts tonecus'){ - steps{ - nexusArtifactUploader artifacts: [[artifactId: 'CounterWebApp', classifier: '', file: '/var/lib/jenkins/workspace/declarative-pipeline/target/CounterWebApp.war', type: 'WAR']], credentialsId: 'nexus', groupId: 'com.mkyong', nexusUrl: '172.31.9.61:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-snapshots', version: '1.0-SNAPSHOT' - } - } - stage('deploy to prod') { + stage ('Prod Aprove') { + steps { + echo "taking approval from Prod manager for Prod Deployment" + timeout(time: 7, unit: 'DAYS') { + input message: 'Do you approve Prod Deployment?', submitter: 'admin' + } + } + } + stage('deploy to prod') { steps { - deploy adapters: [tomcat9(credentialsId: 'tomcat-server', path: '', url: 'http://172.31.91.56:8080/')], contextPath: null, war: '**/*.war' - } + script { + try { + deploy adapters: [tomcat9(alternativeDeploymentContext: '', credentialsId: 'tomcatdeployer', path: '', url: 'http://172.25.0.229:8080')], contextPath: null, war: '**/*.war' + slackSend(channel: 'ci-cd-alerts', color: 'good', message: "Prod Deployment was successful! here is the Job Name: ${env.JOB_NAME} Build Num: ${env.BUILD_NUMBER} (${env.BUILD_URL})", teamDomain: 'keyspaceitsgroup', tokenCredentialId: 'slackcred') + } catch (Exception e) { + slackSend(channel: 'ci-cd-alerts', color: 'danger', message: "Prod Deployment Failed! here is the Job Name: ${env.JOB_NAME} Build Num: ${env.BUILD_NUMBER} (${env.BUILD_URL})", teamDomain: 'keyspaceitsgroup', tokenCredentialId: 'slackcred') + error 'Deployment failed' + } + } + } } } }