From 194a988b93e28bd324718040b1535ba512850aed Mon Sep 17 00:00:00 2001 From: sudipto naskar <124718557+sudip243@users.noreply.github.com> Date: Sat, 18 Mar 2023 23:50:44 +0530 Subject: [PATCH 1/7] Create scripted-jenkins --- scripted-jenkins | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 scripted-jenkins diff --git a/scripted-jenkins b/scripted-jenkins new file mode 100644 index 0000000..47747d9 --- /dev/null +++ b/scripted-jenkins @@ -0,0 +1,18 @@ +node { + def mavenHome = tool name :"mvn3.9.1" + //checkout stage + stage('checkout code'){ + git 'https://github.com/sudip243/Todolist.git' + } + //build stage + stage('build'){ + sh "$mavenHome/bin/mvn clean package" + } + //deploy app into tomcat + stage("deploy app into tomcat"){ + sshagent(['99b72b94-4f0c-4f2f-9957-0a475182f94f']) { + // some block + sh "scp -O StrictHostKeyChecking=no target/SemesterProject.war ubuntu@13.58.199.119/opt/apache-tomcat-10.1.7/webapps" +} + } +} From cf89837663f9b94c1b5197d042b62311cfb9c339 Mon Sep 17 00:00:00 2001 From: sudipto naskar <124718557+sudip243@users.noreply.github.com> Date: Sun, 2 Apr 2023 22:56:15 +0530 Subject: [PATCH 2/7] Update scripted-jenkins --- scripted-jenkins | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/scripted-jenkins b/scripted-jenkins index 47747d9..f03f994 100644 --- a/scripted-jenkins +++ b/scripted-jenkins @@ -1,18 +1,10 @@ node { - def mavenHome = tool name :"mvn3.9.1" + def mavenHome = tool name : "mvn3.9.1" //checkout stage - stage('checkout code'){ + stage ('checkout Code') { git 'https://github.com/sudip243/Todolist.git' } - //build stage - stage('build'){ + stage ('Build') { sh "$mavenHome/bin/mvn clean package" } - //deploy app into tomcat - stage("deploy app into tomcat"){ - sshagent(['99b72b94-4f0c-4f2f-9957-0a475182f94f']) { - // some block - sh "scp -O StrictHostKeyChecking=no target/SemesterProject.war ubuntu@13.58.199.119/opt/apache-tomcat-10.1.7/webapps" -} - } -} +}//closing node From 8ed883df97443ead5a994bf0924023531b6c90ad Mon Sep 17 00:00:00 2001 From: sudipto naskar <124718557+sudip243@users.noreply.github.com> Date: Sun, 2 Apr 2023 23:21:47 +0530 Subject: [PATCH 3/7] Create declatariveway-script --- declatariveway-script | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 declatariveway-script diff --git a/declatariveway-script b/declatariveway-script new file mode 100644 index 0000000..9ea8bb6 --- /dev/null +++ b/declatariveway-script @@ -0,0 +1,27 @@ +pipeline { + triggers { + pollSCM '* * * * *' +} + options { + buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '2', numToKeepStr: '2') +} + agent any + + tools { + // Install the Maven version configured as "M3" and add it to the path. + maven "mvn3.9.1" + } + + stages { + stage('checkoutcode') { + steps { + git 'https://github.com/sudip243/Todolist.git' + } + } + stage('build') { + steps { + sh "mvn clean package" + } + } + } +} From 09edc2fb243f892bd4203b086aed518162bed3b4 Mon Sep 17 00:00:00 2001 From: sudipto naskar <124718557+sudip243@users.noreply.github.com> Date: Wed, 5 Apr 2023 08:32:20 +0530 Subject: [PATCH 4/7] 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..c3b615e --- /dev/null +++ b/dockerfile @@ -0,0 +1,2 @@ +FROM tomcat:8.0.20-jre8 +COPY target/Todolist.war /usr/local/tomcat/webapps/Todolist.war From 11d866fd5701090d1297d4b055f845fbe35fa061 Mon Sep 17 00:00:00 2001 From: sudipto naskar <124718557+sudip243@users.noreply.github.com> Date: Wed, 5 Apr 2023 08:53:45 +0530 Subject: [PATCH 5/7] Update dockerfile --- dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index c3b615e..2400dac 100644 --- a/dockerfile +++ b/dockerfile @@ -1,2 +1,2 @@ FROM tomcat:8.0.20-jre8 -COPY target/Todolist.war /usr/local/tomcat/webapps/Todolist.war +COPY target/SemesterProject.war /usr/local/tomcat/webapps/SemesterProject.war From bfde01d296da725356761892a91f6da4a37ce600 Mon Sep 17 00:00:00 2001 From: sudipto naskar <124718557+sudip243@users.noreply.github.com> Date: Sat, 15 Apr 2023 20:28:17 +0530 Subject: [PATCH 6/7] Create jenkinspipeline tomcat deployment --- jenkinspipeline tomcat deployment | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 jenkinspipeline tomcat deployment diff --git a/jenkinspipeline tomcat deployment b/jenkinspipeline tomcat deployment new file mode 100644 index 0000000..3c05130 --- /dev/null +++ b/jenkinspipeline tomcat deployment @@ -0,0 +1,17 @@ +node { + //checkout stage + stage ('checkout'){ + git 'https://github.com/sudip243/Todolist.git' + } + //build stage + stage ('build'){ + sh "mvn clean package" + } + //deploy app into tomacat server + stage ('deploy into tomcat'){ + sshagent(['9c752a68-2ab7-4ce5-98d3-651ae91cfb14']) { + sh "scp -o StrictHostKeyChecking=no target/SemesterProject.war ubuntu@172.31.94.104:/opt/apache-tomcat-9.0.73/webapps" +} + } + +}//closing node From da3ad60f7e20b8cd695428f2870baeba033e3238 Mon Sep 17 00:00:00 2001 From: sudipto naskar <124718557+sudip243@users.noreply.github.com> Date: Sun, 25 Jun 2023 01:51:18 +0530 Subject: [PATCH 7/7] Create jenkins_docker-integration --- jenkins_docker-integration | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 jenkins_docker-integration diff --git a/jenkins_docker-integration b/jenkins_docker-integration new file mode 100644 index 0000000..eeb5445 --- /dev/null +++ b/jenkins_docker-integration @@ -0,0 +1,26 @@ +node{ + def buildNumber = BUILD_NUMBER + stage("Git Clone"){ + git 'https://github.com/sudip243/Todolist.git' + } + stage("Maven Clean Package"){ + def mavenHome= tool name: "mvn3.9.2",type: "maven" + sh "${mavenHome}/bin/mvn clean package" + } + stage("Build Docker Image"){ + sh "docker build -t sudipto243/java-web-app:${buildNumber} ." + } + stage("Docker login and Push"){ + withCredentials([string(credentialsId: 'dockerhubpass', variable: 'dockerhubpass')]) { + sh "docker login -u sudipto243 -p ${dockerhubpass}" +} + sh "docker push sudipto243/java-web-app:${buildNumber}" + } + stage("Deploy application as docker container in docker deployment server"){ + sshagent(['docker_dev_server_ssh']) { + sh "ssh -o StrictHostkeyChecking=no ubuntu@172.31.0.85 docker rm -f javawebappcontainer || true" + sh "ssh -o StrictHostkeyChecking=no ubuntu@172.31.0.85 docker run -d -p 8080:8080 --name javawebappcontainer sudipto243/java-web-app:${buildNumber}" +} + } +} +