From f2da528dfdc7c4906e5639afa5f4a824ae6c4040 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:36:05 +0530 Subject: [PATCH 01/35] Update pom.xml From 0ce7fffd06451c481ab148e721c58a1d828397cd Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:36:28 +0530 Subject: [PATCH 02/35] Update Jenkinsfile --- Jenkinsfile | 88 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f1f2e9e3..27f51115 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,33 +1,93 @@ pipeline { agent any tools { - maven 'localMaven' + maven "localMaven" + jdk "Java8" } - parameters { - string(name: 'tomcat_stag', defaultValue: '35.154.81.229', description: 'Tomcat Staging Server') + environment { + // This can be nexus3 or nexus2 + NEXUS_VERSION = "nexus3" + // This can be http or https + NEXUS_PROTOCOL = "http" + // Where your Nexus is running + NEXUS_URL = "65.2.189.169:8081" + // Repository where we will upload the artifact + NEXUS_REPOSITORY = "LoginWebApp" + // Jenkins credential id to authenticate to Nexus OSS + NEXUS_CREDENTIAL_ID = "nexusCredential" + ARTIFACT_VERSION = "${BUILD_NUMBER}" } -stages{ - stage('Build'){ + stages { + stage("Check out") { steps { - sh 'mvn clean package' + script { + git branch: 'feature/nexusUpload', url: 'https://github.com/ranjit4github/LoginWebApp.git'; + } } - post { - success { - echo 'Archiving the artifacts' - archiveArtifacts artifacts: '**/*.war' + } + + stage("mvn build") { + steps { + script { + sh "mvn clean package" } } } - stage ('Deployments'){ - stage ('Deploy to Staging Server'){ - steps { - sh "scp **/*.war jenkins@${params.tomcat_stag}:/usr/share/tomcat/webapps" + stage("publish to nexus") { + steps { + script { + // Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps + pom = readMavenPom file: "pom.xml"; + // Find built artifact under target folder + filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); + // Print some info from the artifact found + echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" + // Extract the path from the File found + artifactPath = filesByGlob[0].path; + // Assign to a boolean response verifying If the artifact name exists + artifactExists = fileExists artifactPath; + + if(artifactExists) { + echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; + + nexusArtifactUploader( + nexusVersion: NEXUS_VERSION, + protocol: NEXUS_PROTOCOL, + nexusUrl: NEXUS_URL, + groupId: pom.groupId, + version: ARTIFACT_VERSION, + repository: NEXUS_REPOSITORY, + credentialsId: NEXUS_CREDENTIAL_ID, + artifacts: [ + // Artifact generated such as .jar, .ear and .war files. + [artifactId: pom.artifactId, + classifier: '', + file: artifactPath, + type: pom.packaging] + ] + ); + + } else { + error "*** File: ${artifactPath}, could not be found"; } } } } + stage ('Execute Ansible Play - CD'){ + agent { + label 'ansible' + } + steps{ + script { + git branch: 'feature/ansibleNexus', url: 'https://github.com/ranjit4github/Ansible_Demo_Project.git'; + } + sh ''' + ansible-playbook -e vers=${BUILD_NUMBER} roles/site.yml + ''' + } + } } } From cd754eecd99308fe69f9d077ec76a57f99e2d911 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:37:31 +0530 Subject: [PATCH 03/35] Delete .project --- .project | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index d72bb832..00000000 --- a/.project +++ /dev/null @@ -1,36 +0,0 @@ - - - LoginWebApp - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - - From 7aae78f0444e3cea94d727da61c93e835cde262a Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:37:38 +0530 Subject: [PATCH 04/35] Delete Dockerfile-tomcat --- Dockerfile-tomcat | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 Dockerfile-tomcat diff --git a/Dockerfile-tomcat b/Dockerfile-tomcat deleted file mode 100644 index 0cc4017a..00000000 --- a/Dockerfile-tomcat +++ /dev/null @@ -1,9 +0,0 @@ -#Base image -FROM tomcat:8.5 - -#COPY -COPY ./target/LoginWebApp.war /usr/local/tomcat/webapps/ - -WORKDIR /usr/local/tomcat/webapps/ - -CMD ["catalina.sh", "run"] From b6b751f4cee5b8e32d5220b5a4feb677c5c0d4a2 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:37:48 +0530 Subject: [PATCH 05/35] Delete Dockerfile-mysql --- Dockerfile-mysql | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Dockerfile-mysql diff --git a/Dockerfile-mysql b/Dockerfile-mysql deleted file mode 100644 index fa3aefdc..00000000 --- a/Dockerfile-mysql +++ /dev/null @@ -1,5 +0,0 @@ -#Base image -FROM mysql:5.7.28 - -#COPY -COPY ./dump/devopsclass.sql /docker-entrypoint-initdb.d From af0053415b1e2429171bed56fb0c76ece19b57f8 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:37:59 +0530 Subject: [PATCH 06/35] Delete .classpath --- .classpath | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 .classpath diff --git a/.classpath b/.classpath deleted file mode 100644 index a9deb857..00000000 --- a/.classpath +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From fa6fab5bd5182811006d748db288b850c4b8e8c1 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:42:38 +0530 Subject: [PATCH 07/35] Update Jenkinsfile --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 27f51115..786392f6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,8 @@ pipeline { agent any tools { - maven "localMaven" - jdk "Java8" + maven "MAVEN" + jdk "JDK" } environment { @@ -11,11 +11,11 @@ pipeline { // This can be http or https NEXUS_PROTOCOL = "http" // Where your Nexus is running - NEXUS_URL = "65.2.189.169:8081" + NEXUS_URL = "13.126.159.57:8081" // Repository where we will upload the artifact - NEXUS_REPOSITORY = "LoginWebApp" + NEXUS_REPOSITORY = "logicwebapp" // Jenkins credential id to authenticate to Nexus OSS - NEXUS_CREDENTIAL_ID = "nexusCredential" + NEXUS_CREDENTIAL_ID = "Nexus" ARTIFACT_VERSION = "${BUILD_NUMBER}" } From eb003928bb35fa84f6f82f6e539e0049eb9b3cdb Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:45:51 +0530 Subject: [PATCH 08/35] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 786392f6..e5f227ae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { stage("Check out") { steps { script { - git branch: 'feature/nexusUpload', url: 'https://github.com/ranjit4github/LoginWebApp.git'; + git branch: 'feature/nexusUpload', url: 'https://github.com/PSRINVAS-729/LoginWebApp.git'; } } } From b79b61455dafa089f2784ca513ba9b147ed02250 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:46:59 +0530 Subject: [PATCH 09/35] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 86876305..7c490533 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,8 @@ 4.0.0 - com.ranjitswain - LoginWebApp + com.PSRINIVAS-729 + logicwebapp war 1.0-SNAPSHOT LoginWebApp Maven Webapp From 26aeb368744f9357bb11dcd637753c9790708c4b Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:53:43 +0530 Subject: [PATCH 10/35] Update Jenkinsfile --- Jenkinsfile | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e5f227ae..970beabe 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,18 +76,18 @@ pipeline { } } } - stage ('Execute Ansible Play - CD'){ - agent { - label 'ansible' - } - steps{ - script { - git branch: 'feature/ansibleNexus', url: 'https://github.com/ranjit4github/Ansible_Demo_Project.git'; - } - sh ''' - ansible-playbook -e vers=${BUILD_NUMBER} roles/site.yml - ''' - } - } + // stage ('Execute Ansible Play - CD'){ + // agent { + // label 'ansible' + // } + // steps{ + // script { + // git branch: 'feature/ansibleNexus', url: 'https://github.com/ranjit4github/Ansible_Demo_Project.git'; + // } + // sh ''' + // ansible-playbook -e vers=${BUILD_NUMBER} roles/site.yml + // ''' + // } + // } } } From a12d8d3eb492ef1496c883e525dbcd91a6d2a270 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:55:44 +0530 Subject: [PATCH 11/35] Update Jenkinsfile --- Jenkinsfile | 74 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 970beabe..6482f28a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,46 +36,46 @@ pipeline { } } - stage("publish to nexus") { - steps { - script { - // Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps - pom = readMavenPom file: "pom.xml"; - // Find built artifact under target folder - filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); - // Print some info from the artifact found - echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" - // Extract the path from the File found - artifactPath = filesByGlob[0].path; - // Assign to a boolean response verifying If the artifact name exists - artifactExists = fileExists artifactPath; + // stage("publish to nexus") { + // steps { + // script { + // // Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps + // pom = readMavenPom file: "pom.xml"; + // // Find built artifact under target folder + // filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); + // // Print some info from the artifact found + // echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" + // // Extract the path from the File found + // artifactPath = filesByGlob[0].path; + // // Assign to a boolean response verifying If the artifact name exists + // artifactExists = fileExists artifactPath; - if(artifactExists) { - echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; + // if(artifactExists) { + // echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; - nexusArtifactUploader( - nexusVersion: NEXUS_VERSION, - protocol: NEXUS_PROTOCOL, - nexusUrl: NEXUS_URL, - groupId: pom.groupId, - version: ARTIFACT_VERSION, - repository: NEXUS_REPOSITORY, - credentialsId: NEXUS_CREDENTIAL_ID, - artifacts: [ - // Artifact generated such as .jar, .ear and .war files. - [artifactId: pom.artifactId, - classifier: '', - file: artifactPath, - type: pom.packaging] - ] - ); + // nexusArtifactUploader( + // nexusVersion: NEXUS_VERSION, + // protocol: NEXUS_PROTOCOL, + // nexusUrl: NEXUS_URL, + // groupId: pom.groupId, + // version: ARTIFACT_VERSION, + // repository: NEXUS_REPOSITORY, + // credentialsId: NEXUS_CREDENTIAL_ID, + // artifacts: [ + // // Artifact generated such as .jar, .ear and .war files. + // [artifactId: pom.artifactId, + // classifier: '', + // file: artifactPath, + // type: pom.packaging] + // ] + // ); - } else { - error "*** File: ${artifactPath}, could not be found"; - } - } - } - } + // } else { + // error "*** File: ${artifactPath}, could not be found"; + // } + // } + // } + // } // stage ('Execute Ansible Play - CD'){ // agent { // label 'ansible' From 19aceb10f89c28387e292f635ff10751105a8d42 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:57:00 +0530 Subject: [PATCH 12/35] Update Jenkinsfile --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6482f28a..44a99005 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,13 +28,13 @@ pipeline { } } - stage("mvn build") { - steps { - script { - sh "mvn clean package" - } - } - } + // stage("mvn build") { + // steps { + // script { + // sh "mvn clean package" + // } + // } + // } // stage("publish to nexus") { // steps { From 52b8189efc4093363be8de08a0370f3d399a6163 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:57:50 +0530 Subject: [PATCH 13/35] Update Jenkinsfile --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 44a99005..0ec5b011 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,13 +28,13 @@ pipeline { } } - // stage("mvn build") { - // steps { - // script { - // sh "mvn clean package" - // } - // } - // } + stage("mvn build") { + steps { + script { + sh "mvn clean install" + } + } + } // stage("publish to nexus") { // steps { From b152f5cb82443f139e652dd62298decd7d3a9f6f Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:03:24 +0530 Subject: [PATCH 14/35] Update Jenkinsfile --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0ec5b011..b7fa01fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,9 +30,7 @@ pipeline { stage("mvn build") { steps { - script { sh "mvn clean install" - } } } From efc7d3f836c7c8565210ae941abf3f8382d1b14e Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:10:23 +0530 Subject: [PATCH 15/35] Update Jenkinsfile --- Jenkinsfile | 72 +++++++++++++++-------------------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b7fa01fa..5877a89b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,62 +30,30 @@ pipeline { stage("mvn build") { steps { - sh "mvn clean install" + sh "mvn clean package -DskipTests" } } - // stage("publish to nexus") { - // steps { - // script { - // // Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps - // pom = readMavenPom file: "pom.xml"; - // // Find built artifact under target folder - // filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); - // // Print some info from the artifact found - // echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" - // // Extract the path from the File found - // artifactPath = filesByGlob[0].path; - // // Assign to a boolean response verifying If the artifact name exists - // artifactExists = fileExists artifactPath; - - // if(artifactExists) { - // echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; + stage("Upload Artifact to Nexus") { + steps { + script { + def artifactPath = "target/nexus-1.0.jar" // Update artifact name + def artifactName = "nexus-1.0.jar" - // nexusArtifactUploader( - // nexusVersion: NEXUS_VERSION, - // protocol: NEXUS_PROTOCOL, - // nexusUrl: NEXUS_URL, - // groupId: pom.groupId, - // version: ARTIFACT_VERSION, - // repository: NEXUS_REPOSITORY, - // credentialsId: NEXUS_CREDENTIAL_ID, - // artifacts: [ - // // Artifact generated such as .jar, .ear and .war files. - // [artifactId: pom.artifactId, - // classifier: '', - // file: artifactPath, - // type: pom.packaging] - // ] - // ); + sh """ + curl -v -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} --upload-file ${artifactPath} ${NEXUS_URL}${artifactName} + """ + } + } + } + } - // } else { - // error "*** File: ${artifactPath}, could not be found"; - // } - // } - // } - // } - // stage ('Execute Ansible Play - CD'){ - // agent { - // label 'ansible' - // } - // steps{ - // script { - // git branch: 'feature/ansibleNexus', url: 'https://github.com/ranjit4github/Ansible_Demo_Project.git'; - // } - // sh ''' - // ansible-playbook -e vers=${BUILD_NUMBER} roles/site.yml - // ''' - // } - // } + post { + success { + echo "✅ Build and Artifact Upload Successful!" + } + failure { + echo "❌ Build or Artifact Upload Failed. Check Logs!" + } } } From 1b40365ae3049e71def80382c6eeec43309c924f Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:13:23 +0530 Subject: [PATCH 16/35] Update pom.xml --- pom.xml | 100 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index 7c490533..48caade7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,30 +1,72 @@ - - 4.0.0 - com.PSRINIVAS-729 - logicwebapp - war - 1.0-SNAPSHOT - LoginWebApp Maven Webapp - http://maven.apache.org - - - javax.servlet - servlet-api - 2.5 - - - mysql - mysql-connector-java - 8.0.12 - - - junit - junit - 4.10 - - - - LoginWebApp - + + + 4.0.0 + + com.PSRINIVAS-729 + logicwebapp + war + 1.0-SNAPSHOT + + LoginWebApp Maven Webapp + http://maven.apache.org + + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + + + mysql + mysql-connector-java + 8.0.12 + + + + + junit + junit + 4.13.2 + test + + + + + LoginWebApp + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + + + + + central + https://repo.maven.apache.org/maven2 + + + From cc19618671d94d65575295bdd6ef771363191985 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:14:53 +0530 Subject: [PATCH 17/35] Update pom.xml From 2a832952bb205b2df7aba8dc6b728b5679733d0e Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:15:16 +0530 Subject: [PATCH 18/35] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5877a89b..25901f94 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ pipeline { stage("mvn build") { steps { - sh "mvn clean package -DskipTests" + sh "mvn clean install" } } From 9c81ba7680ab81438a6ad2a3ab159d055ddd9715 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:18:01 +0530 Subject: [PATCH 19/35] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 25901f94..3b824b5b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ pipeline { stage("mvn build") { steps { - sh "mvn clean install" + sh "mvn clean install -X" } } From 464e42b0cb940555268dc5eda56c13fc7d072212 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:21:02 +0530 Subject: [PATCH 20/35] Update Jenkinsfile --- Jenkinsfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b824b5b..bf75afe2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,18 +34,18 @@ pipeline { } } - stage("Upload Artifact to Nexus") { - steps { - script { - def artifactPath = "target/nexus-1.0.jar" // Update artifact name - def artifactName = "nexus-1.0.jar" + // stage("Upload Artifact to Nexus") { + // steps { + // script { + // def artifactPath = "target/nexus-1.0.jar" // Update artifact name + // def artifactName = "nexus-1.0.jar" - sh """ - curl -v -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} --upload-file ${artifactPath} ${NEXUS_URL}${artifactName} - """ - } - } - } + // sh """ + // curl -v -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} --upload-file ${artifactPath} ${NEXUS_URL}${artifactName} + // """ + // } + // } + // } } post { From 6ba56f567d594fa16243b7e8a6ff640f78ccd381 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:23:01 +0530 Subject: [PATCH 21/35] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf75afe2..08b94165 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ pipeline { stage("mvn build") { steps { - sh "mvn clean install -X" + sh "mvn clean install" } } From a9a2ca71c400399904d4e4702daee819d39633a2 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:23:58 +0530 Subject: [PATCH 22/35] Update Jenkinsfile --- Jenkinsfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 08b94165..25901f94 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,18 +34,18 @@ pipeline { } } - // stage("Upload Artifact to Nexus") { - // steps { - // script { - // def artifactPath = "target/nexus-1.0.jar" // Update artifact name - // def artifactName = "nexus-1.0.jar" + stage("Upload Artifact to Nexus") { + steps { + script { + def artifactPath = "target/nexus-1.0.jar" // Update artifact name + def artifactName = "nexus-1.0.jar" - // sh """ - // curl -v -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} --upload-file ${artifactPath} ${NEXUS_URL}${artifactName} - // """ - // } - // } - // } + sh """ + curl -v -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} --upload-file ${artifactPath} ${NEXUS_URL}${artifactName} + """ + } + } + } } post { From d623c4b51b3fc6854ac25c5b4ea5f9c64011d09d Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:26:30 +0530 Subject: [PATCH 23/35] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 25901f94..2def6f4b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,8 +37,8 @@ pipeline { stage("Upload Artifact to Nexus") { steps { script { - def artifactPath = "target/nexus-1.0.jar" // Update artifact name - def artifactName = "nexus-1.0.jar" + def artifactPath = "target/LoginWebApp.war" // Update artifact name + def artifactName = "LoginWebApp.war" sh """ curl -v -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} --upload-file ${artifactPath} ${NEXUS_URL}${artifactName} From 1c15625e483d3c5816982bd1a0097ddd13eead4e Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:29:18 +0530 Subject: [PATCH 24/35] Update Jenkinsfile --- Jenkinsfile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2def6f4b..00478868 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,15 +37,18 @@ pipeline { stage("Upload Artifact to Nexus") { steps { script { - def artifactPath = "target/LoginWebApp.war" // Update artifact name - def artifactName = "LoginWebApp.war" + withCredentials([usernamePassword(credentialsId: "${NEXUS_CREDENTIAL_ID}", usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASS')]) { + def artifactPath = "target/LoginWebApp.war" + def artifactName = "LoginWebApp-${ARTIFACT_VERSION}.war" + def nexusUploadUrl = "${NEXUS_PROTOCOL}://${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/${artifactName}" - sh """ - curl -v -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} --upload-file ${artifactPath} ${NEXUS_URL}${artifactName} - """ + sh """ + echo "Uploading ${artifactName} to Nexus..." + curl -v -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file ${artifactPath} ${nexusUploadUrl} + """ + } } } - } } post { @@ -57,3 +60,4 @@ pipeline { } } } +} From c204de1d0411f93360cb828f9884045775801cdc Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:30:12 +0530 Subject: [PATCH 25/35] Update Jenkinsfile --- Jenkinsfile | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 00478868..7bdf3f5b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,35 +6,30 @@ pipeline { } environment { - // This can be nexus3 or nexus2 - NEXUS_VERSION = "nexus3" - // This can be http or https - NEXUS_PROTOCOL = "http" - // Where your Nexus is running - NEXUS_URL = "13.126.159.57:8081" - // Repository where we will upload the artifact - NEXUS_REPOSITORY = "logicwebapp" - // Jenkins credential id to authenticate to Nexus OSS - NEXUS_CREDENTIAL_ID = "Nexus" - ARTIFACT_VERSION = "${BUILD_NUMBER}" + NEXUS_VERSION = "nexus3" // Nexus 3 or Nexus 2 + NEXUS_PROTOCOL = "http" // HTTP or HTTPS + NEXUS_URL = "13.126.159.57:8081" // Nexus Server IP and Port + NEXUS_REPOSITORY = "logicwebapp" // Nexus Repository Name + NEXUS_CREDENTIAL_ID = "Nexus" // Jenkins Credential ID for Nexus + ARTIFACT_VERSION = "${BUILD_NUMBER}" // Versioning } stages { - stage("Check out") { + stage("Checkout Code") { steps { script { - git branch: 'feature/nexusUpload', url: 'https://github.com/PSRINVAS-729/LoginWebApp.git'; + git branch: 'feature/nexusUpload', url: 'https://github.com/PSRINVAS-729/LoginWebApp.git' } } } - stage("mvn build") { + stage("Maven Build") { steps { - sh "mvn clean install" + sh "mvn clean install" } } - stage("Upload Artifact to Nexus") { + stage("Upload Artifact to Nexus") { steps { script { withCredentials([usernamePassword(credentialsId: "${NEXUS_CREDENTIAL_ID}", usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASS')]) { @@ -49,6 +44,7 @@ pipeline { } } } + } } post { @@ -60,4 +56,3 @@ pipeline { } } } -} From c4ab4618e797406c88fa4a52bf627a9e1910fe70 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:47:52 +0530 Subject: [PATCH 26/35] Update Jenkinsfile --- Jenkinsfile | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7bdf3f5b..452748d7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,6 +12,8 @@ pipeline { NEXUS_REPOSITORY = "logicwebapp" // Nexus Repository Name NEXUS_CREDENTIAL_ID = "Nexus" // Jenkins Credential ID for Nexus ARTIFACT_VERSION = "${BUILD_NUMBER}" // Versioning + GROUP_ID = "com/psrinivas" + ARTIFACT_ID = "loginwebapp" } stages { @@ -31,17 +33,10 @@ pipeline { stage("Upload Artifact to Nexus") { steps { - script { - withCredentials([usernamePassword(credentialsId: "${NEXUS_CREDENTIAL_ID}", usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASS')]) { - def artifactPath = "target/LoginWebApp.war" - def artifactName = "LoginWebApp-${ARTIFACT_VERSION}.war" - def nexusUploadUrl = "${NEXUS_PROTOCOL}://${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/${artifactName}" - - sh """ - echo "Uploading ${artifactName} to Nexus..." - curl -v -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file ${artifactPath} ${nexusUploadUrl} - """ - } + withCredentials([usernamePassword(credentialsId: 'Nexus', usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASS')]) { + sh """ + curl -v -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file target/LoginWebApp.war ${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/${GROUP_ID}/${ARTIFACT_ID}/${ARTIFACT_VERSION}/${ARTIFACT_ID}-${ARTIFACT_VERSION}.war + """ } } } From 3329e212672e4775720ebbdacda3a4f4aa4bcc2b Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 18:51:48 +0530 Subject: [PATCH 27/35] Update Jenkinsfile --- Jenkinsfile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 452748d7..5539a3f4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,13 +41,4 @@ pipeline { } } } - - post { - success { - echo "✅ Build and Artifact Upload Successful!" - } - failure { - echo "❌ Build or Artifact Upload Failed. Check Logs!" - } - } } From b69344eb15ff02e4793525a659a5a78cad2b6f0f Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:14:50 +0530 Subject: [PATCH 28/35] Update Jenkinsfile --- Jenkinsfile | 75 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5539a3f4..bc21db8f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,48 @@ +// pipeline { +// agent any +// tools { +// maven "MAVEN" +// jdk "JDK" +// } + +// environment { +// NEXUS_VERSION = "nexus3" // Nexus 3 or Nexus 2 +// NEXUS_PROTOCOL = "http" // HTTP or HTTPS +// NEXUS_URL = "13.126.159.57:8081" // Nexus Server IP and Port +// NEXUS_REPOSITORY = "logicwebapp" // Nexus Repository Name +// NEXUS_CREDENTIAL_ID = "Nexus" // Jenkins Credential ID for Nexus +// ARTIFACT_VERSION = "${BUILD_NUMBER}" // Versioning +// GROUP_ID = "com/psrinivas" +// ARTIFACT_ID = "loginwebapp" +// } + +// stages { +// stage("Checkout Code") { +// steps { +// script { +// git branch: 'feature/nexusUpload', url: 'https://github.com/PSRINVAS-729/LoginWebApp.git' +// } +// } +// } + +// stage("Maven Build") { +// steps { +// sh "mvn clean install" +// } +// } + +// stage("Upload Artifact to Nexus") { +// steps { +// withCredentials([usernamePassword(credentialsId: 'Nexus', usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASS')]) { +// sh """ +// curl -v -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file target/LoginWebApp.war ${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/${GROUP_ID}/${ARTIFACT_ID}/${ARTIFACT_VERSION}/${ARTIFACT_ID}-${ARTIFACT_VERSION}.war +// """ +// } +// } +// } +// } +// } +// s3 upload pipeline { agent any tools { @@ -6,22 +51,15 @@ pipeline { } environment { - NEXUS_VERSION = "nexus3" // Nexus 3 or Nexus 2 - NEXUS_PROTOCOL = "http" // HTTP or HTTPS - NEXUS_URL = "13.126.159.57:8081" // Nexus Server IP and Port - NEXUS_REPOSITORY = "logicwebapp" // Nexus Repository Name - NEXUS_CREDENTIAL_ID = "Nexus" // Jenkins Credential ID for Nexus - ARTIFACT_VERSION = "${BUILD_NUMBER}" // Versioning - GROUP_ID = "com/psrinivas" - ARTIFACT_ID = "loginwebapp" + S3_BUCKET = "jenkinss322" + AWS_REGION = "ap-south-1" // Change based on your region + AWS_CREDENTIALS_ID = "s3" } stages { stage("Checkout Code") { steps { - script { - git branch: 'feature/nexusUpload', url: 'https://github.com/PSRINVAS-729/LoginWebApp.git' - } + git branch: 'feature/nexusUpload', url: 'https://github.com/PSRINVAS-729/LoginWebApp.git' } } @@ -31,14 +69,23 @@ pipeline { } } - stage("Upload Artifact to Nexus") { + stage("Upload to S3") { steps { - withCredentials([usernamePassword(credentialsId: 'Nexus', usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASS')]) { + withAWS(credentials: 's3', region: "${AWS_REGION}") { sh """ - curl -v -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file target/LoginWebApp.war ${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/${GROUP_ID}/${ARTIFACT_ID}/${ARTIFACT_VERSION}/${ARTIFACT_ID}-${ARTIFACT_VERSION}.war + aws s3 cp target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war """ } } } } + + post { + success { + echo "✅ Build and Artifact Upload to S3 Successful!" + } + failure { + echo "❌ Build or Artifact Upload to S3 Failed. Check Logs!" + } + } } From ec93f3f6105a78fbae4173773a0d5a1c8a2fb5c8 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:16:49 +0530 Subject: [PATCH 29/35] Update Jenkinsfile --- Jenkinsfile | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bc21db8f..50345c54 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,23 +69,14 @@ pipeline { } } - stage("Upload to S3") { - steps { - withAWS(credentials: 's3', region: "${AWS_REGION}") { - sh """ - aws s3 cp target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war - """ - } - } - } - } - - post { - success { - echo "✅ Build and Artifact Upload to S3 Successful!" - } - failure { - echo "❌ Build or Artifact Upload to S3 Failed. Check Logs!" - } + // stage("Upload to S3") { + // steps { + // withAWS(credentials: 's3', region: "${AWS_REGION}") { + // sh """ + // aws s3 cp target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war + // """ + // } + // } + // } } } From 142a50295c14c839912dd759496f0466aea181db Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:18:31 +0530 Subject: [PATCH 30/35] Update Jenkinsfile --- Jenkinsfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 50345c54..7601155a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,14 +69,14 @@ pipeline { } } - // stage("Upload to S3") { - // steps { - // withAWS(credentials: 's3', region: "${AWS_REGION}") { - // sh """ - // aws s3 cp target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war - // """ - // } - // } - // } + stage("Upload to S3") { + steps { + withAWS(credentials: 's3', region: "${AWS_REGION}") { + sh """ + aws s3 cp target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war + """ + } + } + } } } From e9790b18890f06dd56c223107854f5d38b5eebba Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:35:14 +0530 Subject: [PATCH 31/35] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 7601155a..14f4f980 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,6 +72,7 @@ pipeline { stage("Upload to S3") { steps { withAWS(credentials: 's3', region: "${AWS_REGION}") { + sh 'pwd' sh """ aws s3 cp target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war """ From 56e859a38c71bb5bc85245ba8de7956e0e54a882 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:37:14 +0530 Subject: [PATCH 32/35] Update Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 14f4f980..adc1ce14 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,9 +72,8 @@ pipeline { stage("Upload to S3") { steps { withAWS(credentials: 's3', region: "${AWS_REGION}") { - sh 'pwd' sh """ - aws s3 cp target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war + aws s3 cp /var/lib/jenkins/workspace/s3/target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war """ } } From 258b43b535ddc61d38937bd485b15dd7f73d60c9 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:47:32 +0530 Subject: [PATCH 33/35] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index adc1ce14..8b3c92a0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -73,7 +73,7 @@ pipeline { steps { withAWS(credentials: 's3', region: "${AWS_REGION}") { sh """ - aws s3 cp /var/lib/jenkins/workspace/s3/target/LoginWebApp.war s3://${S3_BUCKET}/LoginWebApp-${BUILD_NUMBER}.war + aws s3 ls """ } } From e03004492434b7e650f4d9cee3c03161c932a889 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:48:40 +0530 Subject: [PATCH 34/35] Update Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8b3c92a0..0091ef45 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,9 +72,7 @@ pipeline { stage("Upload to S3") { steps { withAWS(credentials: 's3', region: "${AWS_REGION}") { - sh """ - aws s3 ls - """ + sh "aws s3 ls" } } } From 470da2e94ef80b82e8136dd311eafda8749e3ad3 Mon Sep 17 00:00:00 2001 From: SRINIVAS_PAKALA <99751793+PSRINVAS-729@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:49:22 +0530 Subject: [PATCH 35/35] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0091ef45..c24a3d94 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,7 +72,7 @@ pipeline { stage("Upload to S3") { steps { withAWS(credentials: 's3', region: "${AWS_REGION}") { - sh "aws s3 ls" + sh "whoami" } } }