From 12859af590a3378438836dca738dd2f9b736b556 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Tue, 19 Apr 2022 13:01:04 +0530 Subject: [PATCH 01/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 38a78cde..95c8670b 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ This is a Sample Maven App. +changed this readme, to test the jenkins app From 2e9d5d8da270dd2a7d269d539c7da3bbd4b7f76e Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Tue, 19 Apr 2022 14:05:35 +0530 Subject: [PATCH 02/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 95c8670b..2c02910d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ This is a Sample Maven App. changed this readme, to test the jenkins app +again changed to check the git From f8bd0cbd25d1b4ff7d501c1bf8360c67752a9d1c Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:04:16 +0530 Subject: [PATCH 03/21] created jenkins file --- Jenkinsfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..cb91a202 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,33 @@ +pipeline { + agent any + + tools{ + maven "Maven 3.6.3" + } + + stages{ + stage("build"){ + steps{ + echo 'compiling sysfoo app...' + sh 'mvn compile' + } + } + stage("test"){ + steps{ + echo 'running unit tests....' + sh 'mvn clean test' + } + } + stage("package"){ + steps{ + echo 'generating artifact....' + sh 'mvn package -DskipTests' + } + } + } + + post{ + always{ + echo 'This pipeline is completed..' + } + } From 2c47e5e17d2fe2061a84ccf17d0dab358d5adea7 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:09:21 +0530 Subject: [PATCH 04/21] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index cb91a202..a756acb2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,3 +31,4 @@ pipeline { echo 'This pipeline is completed..' } } +} From 8e96a8ea8c571e12d566f2a77d34fe25fbaebe80 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:14:52 +0530 Subject: [PATCH 05/21] added artifcates fetch --- Jenkinsfile | 54 +++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a756acb2..04b66113 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,34 +1,36 @@ pipeline { agent any - - tools{ - maven "Maven 3.6.3" - } - - stages{ - stage("build"){ - steps{ - echo 'compiling sysfoo app...' - sh 'mvn compile' - } + stages { + stage('build') { + steps { + echo 'compiling sysfoo app...' + sh 'mvn compile' } - stage("test"){ - steps{ - echo 'running unit tests....' - sh 'mvn clean test' - } + } + + stage('test') { + steps { + echo 'running unit tests....' + sh 'mvn clean test' } - stage("package"){ - steps{ - echo 'generating artifact....' - sh 'mvn package -DskipTests' - } + } + + stage('package') { + steps { + echo 'generating artifact....' + sh 'mvn package -DskipTests' + archiveArtifacts 'target/*.war' } - } + } - post{ - always{ - echo 'This pipeline is completed..' + } + tools { + maven 'Maven 3.6.3' + } + post { + always { + echo 'This pipeline is completed..' } + } -} +} \ No newline at end of file From 2f9e23fe5813b6a3182fe89b49cfe887bc0bb272 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:19:05 +0530 Subject: [PATCH 06/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2c02910d..84045d10 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ This is a Sample Maven App. changed this readme, to test the jenkins app again changed to check the git +updated this file to test scan option From 0121c646ddfba3cbf320602bc192e880ec006ba9 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:28:24 +0530 Subject: [PATCH 07/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 84045d10..7458424e 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,4 @@ This is a Sample Maven App. changed this readme, to test the jenkins app again changed to check the git updated this file to test scan option +this is ti create new branch and pull request From fc579e46fdda66fede2964569caf35ed673b1fa3 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:34:03 +0530 Subject: [PATCH 08/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7458424e..8f9ceb7c 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,4 @@ changed this readme, to test the jenkins app again changed to check the git updated this file to test scan option this is ti create new branch and pull request +test this branching again From bdfe606b2184fa251fe913904cbdcf6495678aa4 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Wed, 20 Apr 2022 12:59:28 +0530 Subject: [PATCH 09/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8f9ceb7c..95c3e0ac 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,4 @@ again changed to check the git updated this file to test scan option this is ti create new branch and pull request test this branching again +test this with permissions From ab0d6d0df302efbb89907cead99d9057cd118d9b Mon Sep 17 00:00:00 2001 From: Mohammed Imran TK Date: Thu, 21 Apr 2022 09:39:47 +0530 Subject: [PATCH 10/21] testing --- test.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.md diff --git a/test.md b/test.md new file mode 100644 index 00000000..e69de29b From b164557e44921e7adf6681f12d78db8ff68ba3ad Mon Sep 17 00:00:00 2001 From: MohammedImrantk31 Date: Fri, 22 Apr 2022 11:36:53 +0530 Subject: [PATCH 11/21] added multi stage Dockerfile to build sysfoo app --- dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 dockerfile diff --git a/dockerfile b/dockerfile new file mode 100644 index 00000000..ebc29d92 --- /dev/null +++ b/dockerfile @@ -0,0 +1,9 @@ +FROM maven:3.6.3-jdk-11-slim as build +WORKDIR /opt/demo +COPY . /opt/demo +RUN mvn package -DskipTests + +FROM tomcat:jre8-openjdk-slim-buster as run +WORKDIR /usr/local/tomcat +COPY --from=build /opt/demo/target/sysfoo.war webapps/ROOT.war + From 2fe23b7ad9c1a4bc5ba886b45d1b15a9879a9830 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:44:45 +0530 Subject: [PATCH 12/21] added docker Bnp --- Jenkinsfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 04b66113..11df12e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,12 @@ pipeline { agent any stages { stage('build') { + agent { + docker { + image 'maven:3.6.3-jdk-11-slim' + } + + } steps { echo 'compiling sysfoo app...' sh 'mvn compile' @@ -9,6 +15,12 @@ pipeline { } stage('test') { + agent { + docker { + image 'maven:3.6.3-jdk-11-slim' + } + + } steps { echo 'running unit tests....' sh 'mvn clean test' @@ -16,6 +28,12 @@ pipeline { } stage('package') { + agent { + docker { + image 'maven:3.6.3-jdk-11-slim' + } + + } steps { echo 'generating artifact....' sh 'mvn package -DskipTests' @@ -23,6 +41,21 @@ pipeline { } } + stage('Docker BnP.') { + agent any + steps { + script { + docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') { + def dockerImage = docker.build("mohammedimrantk/sysfoo:v${env.BUILD_ID}", "./") + dockerImage.push() + dockerImage.push("latest") + dockerImage.push("dev") + } + } + + } + } + } tools { maven 'Maven 3.6.3' From eb6fa5af49a12889c8e9b6830faae09631dfdfec Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:54:43 +0530 Subject: [PATCH 13/21] added branch condition --- Jenkinsfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 11df12e5..3354de31 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,9 +35,13 @@ pipeline { } steps { + + if (env.BRANCH_NAME == 'master'){ echo 'generating artifact....' sh 'mvn package -DskipTests' archiveArtifacts 'target/*.war' + } else { + echo 'This is not master branch'} } } @@ -45,11 +49,14 @@ pipeline { agent any steps { script { + if (env.BRANCH_NAME == 'master'){ docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') { def dockerImage = docker.build("mohammedimrantk/sysfoo:v${env.BUILD_ID}", "./") dockerImage.push() dockerImage.push("latest") - dockerImage.push("dev") + dockerImage.push("dev") } + else { + echo 'This is not master branch'} } } @@ -66,4 +73,4 @@ pipeline { } } -} \ No newline at end of file +} From b95bb53d54519c3cae71b5897f7cd6d0b7e5c0e7 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:56:33 +0530 Subject: [PATCH 14/21] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3354de31..98f7b5f7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -54,8 +54,8 @@ pipeline { def dockerImage = docker.build("mohammedimrantk/sysfoo:v${env.BUILD_ID}", "./") dockerImage.push() dockerImage.push("latest") - dockerImage.push("dev") } - else { + dockerImage.push("dev") + } else { echo 'This is not master branch'} } } From 1413c933f91d855a65289c76118191d2c928adc0 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:57:33 +0530 Subject: [PATCH 15/21] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 98f7b5f7..477c09c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,7 +55,8 @@ pipeline { dockerImage.push() dockerImage.push("latest") dockerImage.push("dev") - } else { + } + }else { echo 'This is not master branch'} } } From a55d709b9dd3b8c0b3661c048703b9ec48943240 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:59:59 +0530 Subject: [PATCH 16/21] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 477c09c3..66025839 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,7 +42,7 @@ pipeline { archiveArtifacts 'target/*.war' } else { echo 'This is not master branch'} - } + } stage('Docker BnP.') { @@ -63,8 +63,8 @@ pipeline { } } - } + tools { maven 'Maven 3.6.3' } From bd84be683f151cb6c4dc60771a28ba0934534fd9 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:04:01 +0530 Subject: [PATCH 17/21] Update Jenkinsfile --- Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 66025839..8c7b0028 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,8 +32,8 @@ pipeline { docker { image 'maven:3.6.3-jdk-11-slim' } - - } +} + steps { if (env.BRANCH_NAME == 'master'){ @@ -44,7 +44,7 @@ pipeline { echo 'This is not master branch'} } - +} stage('Docker BnP.') { agent any steps { @@ -63,7 +63,7 @@ pipeline { } } - } + tools { maven 'Maven 3.6.3' @@ -75,3 +75,4 @@ pipeline { } } + From a8f92250c248fb2f75aa25630d5bcc07196e25a0 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:05:01 +0530 Subject: [PATCH 18/21] added script --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8c7b0028..bf26cfe9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ pipeline { } steps { - + script { if (env.BRANCH_NAME == 'master'){ echo 'generating artifact....' sh 'mvn package -DskipTests' @@ -44,6 +44,7 @@ pipeline { echo 'This is not master branch'} } + } } stage('Docker BnP.') { agent any From 245c1f3f61848fb00348a772ebf2de8cda9c575b Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:23:30 +0530 Subject: [PATCH 19/21] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf26cfe9..0a158d6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,6 +28,7 @@ pipeline { } stage('package') { + parallel{ agent { docker { image 'maven:3.6.3-jdk-11-slim' @@ -61,7 +62,7 @@ pipeline { echo 'This is not master branch'} } } - + } } } From bfa033ba57c3eda5cf1d0d2d2836ffc7e1394b6f Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:25:50 +0530 Subject: [PATCH 20/21] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0a158d6d..83d7d863 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,9 +26,9 @@ pipeline { sh 'mvn clean test' } } - + parallel{ stage('package') { - parallel{ + agent { docker { image 'maven:3.6.3-jdk-11-slim' From 05c775263638ceac0fe6765958b613546696d326 Mon Sep 17 00:00:00 2001 From: MohammedImranTK <62276809+MohammedImranTK@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:30:54 +0530 Subject: [PATCH 21/21] updated the parallel stage --- Jenkinsfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 83d7d863..e872c97f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,8 @@ pipeline { sh 'mvn clean test' } } - parallel{ + stage ('running tests parallel'){ +parallel{ stage('package') { agent { @@ -63,10 +64,12 @@ pipeline { } } } - } + +} +} } - + tools { maven 'Maven 3.6.3' }