From 13201e9d8d06a53274bb2b9899472cfcd6a011fb Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Sat, 25 Nov 2023 15:06:29 +0530 Subject: [PATCH 1/8] Update Dockerfile --- Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2cc589c335b..2d82155d31e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,8 @@ -FROM tomcat:8 -LABEL app=my-app -COPY target/*.war /usr/local/tomcat/webapps/myweb.war +FROM openjdk:11-jre-slim +WORKDIR /app +COPY target/myweb-0.0.9.war /app/ +CMD ["java", "-jar", "myweb-0.0.9.war"] + + + + From 6137b4ac3e07bd12cdf34bc6c5f77c7eefac989d Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Fri, 22 Dec 2023 12:36:48 +0530 Subject: [PATCH 2/8] Update pom.xml --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index 66ca8946c4d..c4a3e246eca 100755 --- a/pom.xml +++ b/pom.xml @@ -41,5 +41,18 @@ 7 1.7 + + + + org.apache.maven.plugins + maven-war-plugin + 3.2.3 + + false + + + + + From ffcf9ccbc32608a395716bc75f7d596f89dbd6cd Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:58:44 +0530 Subject: [PATCH 3/8] Create jenkinsfile.declarative --- jenkinsfile.declarative | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 jenkinsfile.declarative diff --git a/jenkinsfile.declarative b/jenkinsfile.declarative new file mode 100644 index 00000000000..87c1c08bb6d --- /dev/null +++ b/jenkinsfile.declarative @@ -0,0 +1,48 @@ +pipeline { + agent none + + stages { + stage('git checkout') { + agent { + label "maven" + } + steps { + git 'https://github.com/artisenzubair/my-app.git' + } + } + stage('SonarQube Analysis') { + agent { + label "maven" + } + steps { + script { + withSonarQubeEnv('sonarqube') { + withCredentials([string(credentialsId: 'sonarqube', variable: 'SONARQUBE_TOKEN')]) { + sh """mvn clean verify sonar:sonar \ + -Dsonar.projectKey=demo \ + -Dsonar.host.url=http://100.24.253.252:9000 \ + -Dsonar.login=$SONARQUBE_TOKEN""" + } + } + } + } + } + stage('build') { + agent { + label "tomcat" + } + steps { + sh "mvn clean install" + } + } + stage('tomcat') { + agent { + label "tomcat" + } + steps { + sh "cp /home/ubuntu/workspace/assign/target/myweb-0.0.9.war /opt/tomcat/apache-tomcat-9.0.68/webapps/" + } + } + } + } + From 0612eed2b12bc8c0689f83b8a2c65370a72d05ef Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Sun, 24 Dec 2023 18:04:07 +0530 Subject: [PATCH 4/8] Create jenkinsfile.groovy --- jenkinsfile.groovy | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 jenkinsfile.groovy diff --git a/jenkinsfile.groovy b/jenkinsfile.groovy new file mode 100644 index 00000000000..053bbb0fb4a --- /dev/null +++ b/jenkinsfile.groovy @@ -0,0 +1,33 @@ +node { + stage('git checkout') { + // Run on an agent labeled "maven" + checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/artisenzubair/my-app.git']]]) + + } + stage('SonarQube Analysis') { + // Run on an agent labeled "maven" + withSonarQubeEnv('sonarqube') { + withCredentials([string(credentialsId: 'sonarqube', variable: 'SONARQUBE_TOKEN')]) { + // Run Maven and SonarQube analysis + sh """mvn clean verify sonar:sonar \ + -Dsonar.projectKey=demo \ + -Dsonar.host.url=http://100.24.253.252:9000 \ + -Dsonar.login=$SONARQUBE_TOKEN""" + } + } + } + stage('build') { + // Run on an agent labeled "tomcat" + node('tomcat') { + // Run Maven build + sh "mvn clean install" + } + } + stage('tomcat') { + // Run on an agent labeled "tomcat" + node('tomcat') { + // Copy the WAR file to Tomcat webapps directory + sh "cp /home/ubuntu/workspace/assign/target/myweb-0.0.9.war /opt/tomcat/apache-tomcat-9.0.68/webapps/" + } + } +} From 126ecbf0cb2ef059b5dab07bdd05e970bfc7c271 Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Mon, 25 Dec 2023 09:31:23 +0530 Subject: [PATCH 5/8] Update sonar-status-check --- sonar-status-check | 1 - 1 file changed, 1 deletion(-) diff --git a/sonar-status-check b/sonar-status-check index 8f82dc44a33..be266b963f3 100644 --- a/sonar-status-check +++ b/sonar-status-check @@ -43,5 +43,4 @@ node{ teamDomain: 'javahomecloud', tokenCredentialId: 'slack-demo' } - } From 67f019566b6bcfa67d41f8842ab9e56db5afc52a Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Mon, 25 Dec 2023 11:00:27 +0530 Subject: [PATCH 6/8] Update Jenkinsfile --- Jenkinsfile | 60 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b558a5e4b4a..89d9b646e1e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,19 +1,47 @@ -@Library("mylibs") _ pipeline { - agent any - tools { - maven 'maven2' - } - stages{ - stage("Maven Build"){ - steps{ - sh "mvn clean package" - } + agent none + + stages { + stage('git checkout') { + agent { + label "maven" + } + steps { + git 'https://github.com/artisenzubair/my-app.git' + } + } + stage('SonarQube Analysis') { + agent { + label "maven" + } + steps { + script { + withSonarQubeEnv('sonarqube') { + withCredentials([string(credentialsId: 'sonarqube', variable: 'SONARQUBE_TOKEN')]) { + sh """mvn clean verify sonar:sonar \ + -Dsonar.projectKey=demo \ + -Dsonar.host.url=http://100.24.253.252:9000 \ + -Dsonar.login=$SONARQUBE_TOKEN""" + } + } + } + } + } + stage('build') { + agent { + label "tomcat" + } + steps { + sh "mvn clean install" + } + } + stage('tomcat') { + agent { + label "tomcat" + } + steps { + sh "cp /home/ubuntu/workspace/assign/target/myweb-0.0.9.war /opt/tomcat/apache-tomcat-9.0.68/webapps/" + } + } } - stage("Deploy To Dev"){ - steps{ - tomcatDeploy("tomcat-dev","ec2-user",["172.31.13.89","172.31.13.89"]) - } } - } -} From 9d17a0f1f8750b3be836afab39b8edfaf4de6724 Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Mon, 25 Dec 2023 11:32:27 +0530 Subject: [PATCH 7/8] Create jenkinsfile.new --- jenkinsfile.new | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 jenkinsfile.new diff --git a/jenkinsfile.new b/jenkinsfile.new new file mode 100644 index 00000000000..fe8d542456f --- /dev/null +++ b/jenkinsfile.new @@ -0,0 +1,9 @@ +pipeline { + agent any + + stages { + stage('git checkout') { + steps { + git 'https://github.com/artisenzubair/my-app.git' + } + } From b8cdaddb9df04182536a6e65b52d7dacc027947d Mon Sep 17 00:00:00 2001 From: artisenzubair <124689454+artisenzubair@users.noreply.github.com> Date: Mon, 25 Dec 2023 11:35:26 +0530 Subject: [PATCH 8/8] Update jenkinsfile.new --- jenkinsfile.new | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jenkinsfile.new b/jenkinsfile.new index fe8d542456f..a5e53655256 100644 --- a/jenkinsfile.new +++ b/jenkinsfile.new @@ -7,3 +7,5 @@ pipeline { git 'https://github.com/artisenzubair/my-app.git' } } +} +}