From 1655680d5384fa52dfbfb37f7ef947250ae6ea2d Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:09:13 +0530 Subject: [PATCH 01/15] Create Jenkinsfile --- Jenkinsfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..d614e2cab --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,26 @@ +node { + def mvnHome + stage('Preparation') { // for display purposes + // Get some code from a GitHub repository + git branch: 'main', + url: 'https://github.com/rudranshrocks7/pipelines-java.git' + // Get the Maven tool. + // ** NOTE: This 'M3' Maven tool must be configured + // ** in the global configuration. + mvnHome = tool 'M3' + } + stage('Build') { + // Run the maven build + withEnv(["MVN_HOME=$mvnHome"]) { + if (isUnix()) { + sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore clean package' + } else { + bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore clean package/) + } + } + } + stage('Results') { + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts 'target/*.war' + } +} From 52150e67d9d676e907eea0bf5d6029b2348d9af6 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:28:01 +0530 Subject: [PATCH 02/15] Update Jenkinsfile --- Jenkinsfile | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d614e2cab..153c8730d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,26 +1,33 @@ -node { - def mvnHome - stage('Preparation') { // for display purposes - // Get some code from a GitHub repository - git branch: 'main', - url: 'https://github.com/rudranshrocks7/pipelines-java.git' - // Get the Maven tool. - // ** NOTE: This 'M3' Maven tool must be configured - // ** in the global configuration. - mvnHome = tool 'M3' +pipeline { + agent any + + tools { + // Install the Maven version configured as "M3" and add it to the path. + maven "M3" } - stage('Build') { - // Run the maven build - withEnv(["MVN_HOME=$mvnHome"]) { - if (isUnix()) { - sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore clean package' - } else { - bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore clean package/) + + stages { + stage('Build') { + steps { + // Get some code from a GitHub repository + git branch: 'main', + url: 'https://github.com/jglick/simple-maven-project-with-tests.git' + + // Run Maven on a Unix agent. + sh "mvn -Dmaven.test.failure.ignore=true clean package" + + // To run Maven on a Windows agent, use + // bat "mvn -Dmaven.test.failure.ignore=true clean package" + } + + post { + // If Maven was able to run the tests, even if some of the test + // failed, record the test results and archive the jar file. + success { + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts 'target/*.jar' + } } } } - stage('Results') { - junit '**/target/surefire-reports/TEST-*.xml' - archiveArtifacts 'target/*.war' - } } From dca2d7649e639f972b1d83db853c2525402f49c1 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:28:48 +0530 Subject: [PATCH 03/15] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 153c8730d..cce9f4aea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ pipeline { // failed, record the test results and archive the jar file. success { junit '**/target/surefire-reports/TEST-*.xml' - archiveArtifacts 'target/*.jar' + archiveArtifacts 'target/*.war' } } } From 8ec6ed0d0b78f035cf1d59b5b72170d640b9ccf9 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Mon, 7 Aug 2023 11:30:07 +0530 Subject: [PATCH 04/15] Update Demo.java --- src/main/java/com/microsoft/demo/Demo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/microsoft/demo/Demo.java b/src/main/java/com/microsoft/demo/Demo.java index 3ab319fe3..01d240b55 100644 --- a/src/main/java/com/microsoft/demo/Demo.java +++ b/src/main/java/com/microsoft/demo/Demo.java @@ -3,10 +3,10 @@ public class Demo { public void DoSomething(boolean flag){ if(flag){ - System.out.println("I am covered"); + System.out.println("I am covered Yes"); return; } System.out.println("I am not covered"); } -} \ No newline at end of file +} From 96e3caf1d600f4a5826ac2fb431e52a1d899a43e Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:37:53 +0530 Subject: [PATCH 05/15] Added multiple stages in Jenkinsfile --- Jenkinsfile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cce9f4aea..f0b4c16c1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,25 +7,30 @@ pipeline { } stages { - stage('Build') { - steps { + stage('Checkout'){ + steps{ // Get some code from a GitHub repository git branch: 'main', url: 'https://github.com/jglick/simple-maven-project-with-tests.git' - + } + } + stage('Build') { + steps { // Run Maven on a Unix agent. sh "mvn -Dmaven.test.failure.ignore=true clean package" - // To run Maven on a Windows agent, use // bat "mvn -Dmaven.test.failure.ignore=true clean package" } - - post { - // If Maven was able to run the tests, even if some of the test - // failed, record the test results and archive the jar file. - success { - junit '**/target/surefire-reports/TEST-*.xml' - archiveArtifacts 'target/*.war' + } + stage('Deploy'){ + steps{ + post { + // If Maven was able to run the tests, even if some of the test + // failed, record the test results and archive the jar file. + success { + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts 'target/*.war' + } } } } From 2de3d1cccbcfcc399850d9b620c42bebad293261 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:39:21 +0530 Subject: [PATCH 06/15] Update stages in Jenkinsfile --- Jenkinsfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f0b4c16c1..bf93fd4a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,13 +24,15 @@ pipeline { } stage('Deploy'){ steps{ - post { - // If Maven was able to run the tests, even if some of the test - // failed, record the test results and archive the jar file. - success { - junit '**/target/surefire-reports/TEST-*.xml' - archiveArtifacts 'target/*.war' - } + echo 'Deploying' + } + + post { + // If Maven was able to run the tests, even if some of the test + // failed, record the test results and archive the jar file. + success { + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts 'target/*.war' } } } From f06ce627ee63cc9d71af4fcdfe79c1022fe6d272 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:41:28 +0530 Subject: [PATCH 07/15] Update stages Jenkinsfile --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf93fd4a9..a546bbfc1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,8 +7,8 @@ pipeline { } stages { - stage('Checkout'){ - steps{ + stage('Checkout') { + steps { // Get some code from a GitHub repository git branch: 'main', url: 'https://github.com/jglick/simple-maven-project-with-tests.git' @@ -22,8 +22,8 @@ pipeline { // bat "mvn -Dmaven.test.failure.ignore=true clean package" } } - stage('Deploy'){ - steps{ + stage('Deploy') { + steps { echo 'Deploying' } From 1a4302a22a40b57a37075e1e94b70627fa1160f8 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:48:47 +0530 Subject: [PATCH 08/15] Update Jenkinsfile --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index a546bbfc1..0e6d0519b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,6 +14,13 @@ pipeline { url: 'https://github.com/jglick/simple-maven-project-with-tests.git' } } + stage('get_commit_msg') { + steps { + script { + env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() + } + } + } stage('Build') { steps { // Run Maven on a Unix agent. From 187b3d235866e28024f39c83f1f053d3666f91dd Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:57:52 +0530 Subject: [PATCH 09/15] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0e6d0519b..09e84c538 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,6 +18,7 @@ pipeline { steps { script { env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() + echo ${GIT_COMMIT_MSG} } } } From ba80725459d9d5c9d35a89e2b2c8758169b5a4b7 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:01:37 +0530 Subject: [PATCH 10/15] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 09e84c538..27f7e83d3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { steps { script { env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() - echo ${GIT_COMMIT_MSG} + echo $GIT_COMMIT_MSG } } } From 62c958c2de402477740d3ff88e8331eea3b9af34 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:04:57 +0530 Subject: [PATCH 11/15] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 27f7e83d3..93e99e1a4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { steps { script { env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() - echo $GIT_COMMIT_MSG + echo '$GIT_COMMIT_MSG' } } } From 12a873c91bb10851ec3904a10b8d553430fe887e Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:14:54 +0530 Subject: [PATCH 12/15] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 93e99e1a4..09b14c347 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { steps { script { env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() - echo '$GIT_COMMIT_MSG' + echo $env.GIT_COMMIT_MSG } } } From e28b419e181a2162004e3116854ae2eef48e40b1 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:17:08 +0530 Subject: [PATCH 13/15] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 09b14c347..1ab9dc0fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { steps { script { env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() - echo $env.GIT_COMMIT_MSG + echo ${GIT_COMMIT} } } } From e60ccfcaa30169004020bd12d84602df1dfc95b0 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:38:18 +0530 Subject: [PATCH 14/15] Update Jenkinsfile --- Jenkinsfile | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ab9dc0fb..b2e87df03 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,43 +1,42 @@ pipeline { agent any - tools { // Install the Maven version configured as "M3" and add it to the path. maven "M3" } - stages { - stage('Checkout') { + stage ('Checkout') { steps { - // Get some code from a GitHub repository git branch: 'main', - url: 'https://github.com/jglick/simple-maven-project-with-tests.git' + url: 'https://gitlab.com/nanu1605/pipelines-java.git' } } - stage('get_commit_msg') { + stage('Build') { steps { - script { - env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() - echo ${GIT_COMMIT} - } + sh "mvn -Dmaven.test.failure.ignore=true clean package" } } - stage('Build') { + stage('Install') { steps { - // Run Maven on a Unix agent. - sh "mvn -Dmaven.test.failure.ignore=true clean package" - // To run Maven on a Windows agent, use - // bat "mvn -Dmaven.test.failure.ignore=true clean package" + sh "mvn install" } } - stage('Deploy') { + stage ('Deploy') { + when { + branch 'main' + } steps { - echo 'Deploying' + echo "Deploying" + deploy adapters: [tomcat9 ( + credentialsId: 'tomcat-admin', + path: '', + url: 'http://20.230.1.180:8088/' + )], + contextPath: 'finalTest', + onFailure: 'false', + war: '**/*.war' } - post { - // If Maven was able to run the tests, even if some of the test - // failed, record the test results and archive the jar file. success { junit '**/target/surefire-reports/TEST-*.xml' archiveArtifacts 'target/*.war' From cda9b695980a257c7293b818c0c30e794fd5fa17 Mon Sep 17 00:00:00 2001 From: rudranshrocks7 <43137840+rudranshrocks7@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:43:54 +0530 Subject: [PATCH 15/15] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b2e87df03..628f2a1f1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { stage ('Checkout') { steps { git branch: 'main', - url: 'https://gitlab.com/nanu1605/pipelines-java.git' + url: 'https://github.com/rudranshrocks7/pipelines-java.git' } } stage('Build') { @@ -28,9 +28,9 @@ pipeline { steps { echo "Deploying" deploy adapters: [tomcat9 ( - credentialsId: 'tomcat-admin', + credentialsId: 'tomcat', path: '', - url: 'http://20.230.1.180:8088/' + url: 'http://74.249.99.250:8088/' )], contextPath: 'finalTest', onFailure: 'false',