From df7e8f9ac4b2500b8c69f68edffd43d428eca2cf Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 18 Oct 2020 16:13:55 -0400 Subject: [PATCH 01/19] updated something --- Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 73b573f..1b69b80 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ node('node1') { javaHome = tool 'jdk8' } stage('Checkout') { - git 'https://github.com/atinsingh/devopsjava.git' + git url:'https://github.com/atinsingh/devopsjava.git', branch:'master' } stage('Compile') { // Run the maven build @@ -36,4 +36,7 @@ node('node1') { stage('Complete') { sh 'echo completed' } + stage('Notify') { + sh 'echo may be sending email' + } } From 7b0dfb7d186a4254daa24c8fe3815e79ac35d51f Mon Sep 17 00:00:00 2001 From: Atin Singh Date: Wed, 21 Oct 2020 21:19:00 -0400 Subject: [PATCH 02/19] Delete Jenkinsfile --- Jenkinsfile | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 1b69b80..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,42 +0,0 @@ -node('node1') { - def mvnHome - def javaHome - stage('Preparation') { // for display purposes - mvnHome = tool 'm3' - javaHome = tool 'jdk8' - } - stage('Checkout') { - git url:'https://github.com/atinsingh/devopsjava.git', branch:'master' - } - stage('Compile') { - // Run the maven build - withEnv([ "JAVA_HOME=$javaHome", "MVN_HOME=$mvnHome"]) { - sh '"$MVN_HOME/bin/mvn" clean compile' - } - } - stage('Test') { - // Run the maven build - withEnv(["JAVA_HOME=$javaHome", "MVN_HOME=$mvnHome"]) { - sh '"$MVN_HOME/bin/mvn" clean test' - } - } - stage('Publish Test Results') { - junit '**/target/surefire-reports/TEST-*.xml' - - } - stage('Package') { - // Run the maven build - withEnv(["JAVA_HOME=$javaHome", "MVN_HOME=$mvnHome"]) { - sh '"$MVN_HOME/bin/mvn" clean package' - } - } - stage('Archive Artifact') { - archiveArtifacts 'target/*.jar' - } - stage('Complete') { - sh 'echo completed' - } - stage('Notify') { - sh 'echo may be sending email' - } -} From c878eacb54b2cac64787caf773f9e3322493bc28 Mon Sep 17 00:00:00 2001 From: Atin Singh Date: Wed, 21 Oct 2020 21:26:59 -0400 Subject: [PATCH 03/19] abc --- Jenkinsfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..3d1f6f4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,21 @@ +pipeline { + agent any + stages { + stage('Preparation') { + steps { + tool(name: 'm3', type: 'maven') + sh 'echo Preparing ENV' + } + } + + stage('Compile') { + steps { + sh 'echo helloworld' + } + } + + } + environment { + ABC = 'DEF' + } +} \ No newline at end of file From 3e4c16b5770208c6bfdf581a630250644757a0ba Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 11:00:40 -0400 Subject: [PATCH 04/19] Updated Jenkins file --- Jenkinsfile | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3d1f6f4..6c52815 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,21 +1,43 @@ pipeline { agent any + tool{ + maven 'm3' + jdk 'jdk8' + } stages { - stage('Preparation') { + stage('Checkout') { steps { - tool(name: 'm3', type: 'maven') - sh 'echo Preparing ENV' + chckoutscm } } stage('Compile') { steps { - sh 'echo helloworld' + sh 'mvn compile' + } + } + + stage('Test') { + steps { + sh 'mvn test' + } + } + stage('Package') { + steps { + sh 'mvn package' + } + } + + stage('Publish Test Result') { + steps { + junit '**/*.xml' } } } - environment { - ABC = 'DEF' + post { + always { + slackSend channel: 'devops_sept_2020', color: 'red', message: "BUILD FAILD - $JOB_NAME - $BUILD_ID", teamDomain: 'pragraconsulting2020', tokenCredentialId: 'slack' + } } } \ No newline at end of file From be0b1c1f3f884c7285ee66e009d27c84bedb612e Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 11:03:30 -0400 Subject: [PATCH 05/19] Fixed Typo --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6c52815..83f993c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,13 @@ pipeline { agent any - tool{ + tools{ maven 'm3' jdk 'jdk8' } stages { stage('Checkout') { steps { - chckoutscm + checkoutscm } } From 1380ad3f7381cd344f3e797fc3545a42c743b252 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 11:04:16 -0400 Subject: [PATCH 06/19] Fixed Typo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 83f993c..1fbeae6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { stages { stage('Checkout') { steps { - checkoutscm + checkout scm } } From 6502b80063fe68e9480410e35637a42078debfb2 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 11:19:58 -0400 Subject: [PATCH 07/19] Added failing TestCase --- .../io/pragra/learning/demo/DemoApplicationTests.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java b/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java index addf968..a1927b0 100644 --- a/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java +++ b/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java @@ -1,5 +1,6 @@ package io.pragra.learning.demo; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @@ -12,7 +13,7 @@ void contextLoads() { @Test void test1(){ - + } @@ -26,4 +27,10 @@ void test3(){ } + + @Test + void test4(){ + Assertions.fail("Failing "); + } + } From 5c35b140afbae0c62cc0b24c63ff52cd4b63fc63 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 11:22:58 -0400 Subject: [PATCH 08/19] Added failing TestCase --- Jenkinsfile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1fbeae6..6818f1b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,16 +28,13 @@ pipeline { } } - stage('Publish Test Result') { - steps { - junit '**/*.xml' - } - } + } post { always { + junit '**/*.xml' slackSend channel: 'devops_sept_2020', color: 'red', message: "BUILD FAILD - $JOB_NAME - $BUILD_ID", teamDomain: 'pragraconsulting2020', tokenCredentialId: 'slack' } } -} \ No newline at end of file +} From 312035fe37e3471d88f6ec0628bdaabbb7165cd1 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 12:56:14 -0400 Subject: [PATCH 09/19] Added Sonar --- Jenkinsfile | 5 +++++ src/main/java/io/pragra/learning/demo/IndexController.java | 5 +++++ .../java/io/pragra/learning/demo/DemoApplicationTests.java | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6818f1b..3563084 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,6 +17,11 @@ pipeline { } } + stage('SonarQube analysis') { + withSonarQubeEnv(credentialsId: 'sonarqube') { + sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar' + } + } stage('Test') { steps { sh 'mvn test' diff --git a/src/main/java/io/pragra/learning/demo/IndexController.java b/src/main/java/io/pragra/learning/demo/IndexController.java index 898f8d3..141441a 100644 --- a/src/main/java/io/pragra/learning/demo/IndexController.java +++ b/src/main/java/io/pragra/learning/demo/IndexController.java @@ -6,6 +6,11 @@ public class IndexController { @GetMapping("/") public String getHome() { + String param = null; + if(param ==null || param =="") { + System.out.println("Somthign is not right"); + } + return "index"; } } diff --git a/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java b/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java index a1927b0..986adda 100644 --- a/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java +++ b/src/test/java/io/pragra/learning/demo/DemoApplicationTests.java @@ -30,7 +30,7 @@ void test3(){ @Test void test4(){ - Assertions.fail("Failing "); + } } From 7808b0cc6340a164f6c8c2bc150889c258e0ee55 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 12:57:38 -0400 Subject: [PATCH 10/19] Added Sonar --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3563084..b4cf55d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,8 +18,10 @@ pipeline { } stage('SonarQube analysis') { - withSonarQubeEnv(credentialsId: 'sonarqube') { - sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar' + steps { + withSonarQubeEnv(credentialsId: 'sonarqube') { + sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar' + } } } stage('Test') { From b04e611b509ee49f8165f1c28ee220482c4a8ff3 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 12:58:58 -0400 Subject: [PATCH 11/19] Added Sonar --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b4cf55d..0a28080 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,7 @@ pipeline { stage('SonarQube analysis') { steps { - withSonarQubeEnv(credentialsId: 'sonarqube') { + withSonarQubeEnv(credentialsId: 'sonarqube',installationName:'sonarqube') { sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar' } } From 60a47102bc54c93f31291bac632a53eab6f04378 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 13:05:28 -0400 Subject: [PATCH 12/19] Messed Code --- .../pragra/learning/demo/IndexController.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/main/java/io/pragra/learning/demo/IndexController.java b/src/main/java/io/pragra/learning/demo/IndexController.java index 141441a..764a408 100644 --- a/src/main/java/io/pragra/learning/demo/IndexController.java +++ b/src/main/java/io/pragra/learning/demo/IndexController.java @@ -7,8 +7,61 @@ public class IndexController { @GetMapping("/") public String getHome() { String param = null; + int a = 0; + int b = 0; + int sum = 0; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; + sum = a+b; if(param ==null || param =="") { System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); + System.out.println("Somthign is not right"); } return "index"; From d37b207df1603fbfa15ae4d852d815a4de4a7ef9 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 13:07:28 -0400 Subject: [PATCH 13/19] Messed Code --- Jenkinsfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0a28080..053a204 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,6 +24,15 @@ pipeline { } } } + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails + // true = set pipeline to UNSTABLE, false = don't + waitForQualityGate abortPipeline: true + } + } + } stage('Test') { steps { sh 'mvn test' From 7e6f21185995d42de9c02afe0c76cd37a357c80a Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 13:34:22 -0400 Subject: [PATCH 14/19] Messed Code --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 053a204..4b3414c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ pipeline { } stage("Quality Gate") { steps { - timeout(time: 1, unit: 'HOURS') { + timeout(time: 2, unit: 'MINUTES') { // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails // true = set pipeline to UNSTABLE, false = don't waitForQualityGate abortPipeline: true From feaf8cd7a84cb74ca79bddea07bbee2ffc08d703 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 14:06:43 -0400 Subject: [PATCH 15/19] Messed Code --- .../pragra/learning/demo/IndexController.java | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/src/main/java/io/pragra/learning/demo/IndexController.java b/src/main/java/io/pragra/learning/demo/IndexController.java index 764a408..30ec1f4 100644 --- a/src/main/java/io/pragra/learning/demo/IndexController.java +++ b/src/main/java/io/pragra/learning/demo/IndexController.java @@ -6,63 +6,6 @@ public class IndexController { @GetMapping("/") public String getHome() { - String param = null; - int a = 0; - int b = 0; - int sum = 0; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - sum = a+b; - if(param ==null || param =="") { - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - System.out.println("Somthign is not right"); - } return "index"; } From 9a1e4e9d75693e7f5cbb725eee5cba79e34fdc82 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 14:31:27 -0400 Subject: [PATCH 16/19] Messed Code --- Jenkinsfile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 4b3414c..257dde4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,6 +43,47 @@ pipeline { sh 'mvn package' } } + stage ('Artifactory configuration') { + steps { + rtServer ( + id: "art1" + ) + + rtMavenDeployer ( + id: "MAVEN_DEPLOYER", + serverId: "art1", + releaseRepo: "libs-release-local", + snapshotRepo: "libs-snapshot-local" + ) + + rtMavenResolver ( + id: "MAVEN_RESOLVER", + serverId: "art1", + releaseRepo: "libs-release", + snapshotRepo: "libs-snapshot" + ) + } + } + + stage ('Exec Maven') { + steps { + rtMavenRun ( + tool: 'm3', // Tool name from Jenkins configuration + pom: 'pom.xml', + goals: 'install', + deployerId: "MAVEN_DEPLOYER", + resolverId: "MAVEN_RESOLVER" + ) + } + } + + stage ('Publish build info') { + steps { + rtPublishBuildInfo ( + serverId: "art1" + ) + } + } From 42741e6ed9366fd5e061305ef32ed799e58d8b9f Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 14:37:33 -0400 Subject: [PATCH 17/19] Messed Code --- Jenkinsfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 257dde4..518ac04 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,15 +24,15 @@ pipeline { } } } - stage("Quality Gate") { - steps { - timeout(time: 2, unit: 'MINUTES') { - // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails - // true = set pipeline to UNSTABLE, false = don't - waitForQualityGate abortPipeline: true - } - } - } +// stage("Quality Gate") { +// steps { +// timeout(time: 2, unit: 'MINUTES') { +// // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails +// // true = set pipeline to UNSTABLE, false = don't +// waitForQualityGate abortPipeline: true +// } +// } +// } stage('Test') { steps { sh 'mvn test' From c54934f90fe99291df151060b12e3fa3d763f9c1 Mon Sep 17 00:00:00 2001 From: "Singh,Atin" Date: Sun, 25 Oct 2020 14:43:49 -0400 Subject: [PATCH 18/19] Messed Code --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 518ac04..ee888ed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,7 +46,9 @@ pipeline { stage ('Artifactory configuration') { steps { rtServer ( - id: "art1" + id: "art1", + url: "http://3.16.10.158/artifactory", + credentialsId: "artifactory" ) rtMavenDeployer ( From 6ead2f88978698a11678c24baa6b1309e390d4fe Mon Sep 17 00:00:00 2001 From: Atin Singh Date: Sun, 17 Jan 2021 12:40:19 -0500 Subject: [PATCH 19/19] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 234f74c..95bba08 100644 --- a/pom.xml +++ b/pom.xml @@ -9,9 +9,9 @@ io.pragra.learning - demo + pragrapp 0.0.1-SNAPSHOT - demo + pragrapp DemoProject For Devops