From 572c652f88f572082ad9feaf32ab8f706c3534ab Mon Sep 17 00:00:00 2001 From: ShirishaMitti <131024170+ShirishaMitti@users.noreply.github.com> Date: Tue, 9 May 2023 19:56:54 +0530 Subject: [PATCH 1/4] Create Jenkinsfile_Shirisha --- Jenkinsfile_Shirisha | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Jenkinsfile_Shirisha diff --git a/Jenkinsfile_Shirisha b/Jenkinsfile_Shirisha new file mode 100644 index 00000000..c1abddcd --- /dev/null +++ b/Jenkinsfile_Shirisha @@ -0,0 +1,43 @@ +node('nodes') +{ +echo 'Jenkins Node Name:-' +echo "${env.NODE_NAME}" + +properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '2', daysToKeepStr: '', numToKeepStr: '2'))]) + +def MAVEN_HOME = tool name: "Maven - 3.9.1" + +stage('get code from github') +{ +git branch: '${Environment_name}', credentialsId: '47285e52-f8e7-47a4-9570-d36eef4acbee', url: 'https://github.com/ShirishaMitti/maven-web-application.git' +} + +//${Environment_name} is choice parameter & ${Executed_by} is string parameter. +echo "Gihub branch name is ${Environment_name}. Executing Build with parameters by Shirisha." +//echo ${Executed_by} + +stage('Build') +{ +sh "${MAVEN_HOME}/bin/mvn clean package" +} +/* +stage('Deploying war to Tomcat server') +{ +sshagent(['b345b2cc-bb85-4430-b564-02c7ba5b9b4a']) { + // some block +sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war ec2-user@54.167.112.121:/opt/apache-tomcat-9.0.74/webapps" +} +} +stage('Send Email to user after application deployment') +{ +emailext body: '''Hi Shirisha, + +Congrats. Build $BUILD_NUMBER is $BUILD_STATUS. Please check below for more details. + +$BUILD_URL + +Thanks, +Jenkins''', subject: '$PROJECT_NAME ---> Build $BUILD_NUMBER is $BUILD_STATUS', to: 'shirisha.mitti32@gmail.com,raghamitti2@gmail.com' +} +*/ +} From d20da480746b8a5c61155eee1830c5c6c0c837db Mon Sep 17 00:00:00 2001 From: ShirishaMitti <131024170+ShirishaMitti@users.noreply.github.com> Date: Tue, 9 May 2023 20:07:41 +0530 Subject: [PATCH 2/4] Update Jenkinsfile_Shirisha --- Jenkinsfile_Shirisha | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile_Shirisha b/Jenkinsfile_Shirisha index c1abddcd..5537bb24 100644 --- a/Jenkinsfile_Shirisha +++ b/Jenkinsfile_Shirisha @@ -9,11 +9,11 @@ def MAVEN_HOME = tool name: "Maven - 3.9.1" stage('get code from github') { -git branch: '${Environment_name}', credentialsId: '47285e52-f8e7-47a4-9570-d36eef4acbee', url: 'https://github.com/ShirishaMitti/maven-web-application.git' +git branch: 'dev', credentialsId: '47285e52-f8e7-47a4-9570-d36eef4acbee', url: 'https://github.com/ShirishaMitti/maven-web-application.git' } //${Environment_name} is choice parameter & ${Executed_by} is string parameter. -echo "Gihub branch name is ${Environment_name}. Executing Build with parameters by Shirisha." +//echo "Gihub branch name is ${Environment_name}. Executing Build with parameters by Shirisha." //echo ${Executed_by} stage('Build') From 21a41c8f42c9e14409d83108f408df56fd021595 Mon Sep 17 00:00:00 2001 From: ShirishaMitti <131024170+ShirishaMitti@users.noreply.github.com> Date: Tue, 9 May 2023 20:15:05 +0530 Subject: [PATCH 3/4] Update Jenkinsfile_Shirisha --- Jenkinsfile_Shirisha | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Jenkinsfile_Shirisha b/Jenkinsfile_Shirisha index 5537bb24..1aed48b5 100644 --- a/Jenkinsfile_Shirisha +++ b/Jenkinsfile_Shirisha @@ -23,10 +23,7 @@ sh "${MAVEN_HOME}/bin/mvn clean package" /* stage('Deploying war to Tomcat server') { -sshagent(['b345b2cc-bb85-4430-b564-02c7ba5b9b4a']) { - // some block -sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war ec2-user@54.167.112.121:/opt/apache-tomcat-9.0.74/webapps" -} +deploy adapters: [tomcat9(credentialsId: '68d86d50-002c-4342-827e-e473bd0a94c7', path: '', url: 'http://54.167.112.121:1332/')], contextPath: '/mavenSpringWeb_app', war: '**/maven-web-application.war' } stage('Send Email to user after application deployment') { From 3a47aecfda2fa659a617296759307e3d51919645 Mon Sep 17 00:00:00 2001 From: ShirishaMitti <131024170+ShirishaMitti@users.noreply.github.com> Date: Tue, 9 May 2023 20:58:50 +0530 Subject: [PATCH 4/4] Update Jenkinsfile_Shirisha --- Jenkinsfile_Shirisha | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile_Shirisha b/Jenkinsfile_Shirisha index 1aed48b5..780c892f 100644 --- a/Jenkinsfile_Shirisha +++ b/Jenkinsfile_Shirisha @@ -20,11 +20,12 @@ stage('Build') { sh "${MAVEN_HOME}/bin/mvn clean package" } -/* + stage('Deploying war to Tomcat server') { deploy adapters: [tomcat9(credentialsId: '68d86d50-002c-4342-827e-e473bd0a94c7', path: '', url: 'http://54.167.112.121:1332/')], contextPath: '/mavenSpringWeb_app', war: '**/maven-web-application.war' } + stage('Send Email to user after application deployment') { emailext body: '''Hi Shirisha, @@ -36,5 +37,5 @@ $BUILD_URL Thanks, Jenkins''', subject: '$PROJECT_NAME ---> Build $BUILD_NUMBER is $BUILD_STATUS', to: 'shirisha.mitti32@gmail.com,raghamitti2@gmail.com' } -*/ + }