From 772dbc8207654eea272fdd9a2e6d1d046f310b14 Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Sat, 11 Nov 2017 22:05:56 +0530 Subject: [PATCH 1/9] Create Jenkinsfile --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..d7202c9 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,3 @@ +node { + checkout scm +} From 41e5e5b944456c335b8baa56e8c6017285a0936e Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Sat, 11 Nov 2017 22:10:15 +0530 Subject: [PATCH 2/9] Update Jenkinsfile --- Jenkinsfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7202c9..24d31ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,9 @@ node { - checkout scm -} + checkout([ + $class: 'GitSCM', + branches: scm.branches, + doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, + extensions: scm.extensions, + userRemoteConfigs: scm.userRemoteConfigs + ]) + } From 50aa25a508bd9561f7115588734e94eb3eed7057 Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Sat, 11 Nov 2017 22:11:28 +0530 Subject: [PATCH 3/9] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 24d31ad..4951bcd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ node { checkout([ $class: 'GitSCM', - branches: scm.branches, + branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, extensions: scm.extensions, userRemoteConfigs: scm.userRemoteConfigs From d5017e2b651405299106eda2ecc65b482cfadadd Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Sat, 11 Nov 2017 22:18:45 +0530 Subject: [PATCH 4/9] Update Jenkinsfile --- Jenkinsfile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4951bcd..d7202c9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,3 @@ node { - checkout([ - $class: 'GitSCM', - branches: [[name: '*/master']], - doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, - extensions: scm.extensions, - userRemoteConfigs: scm.userRemoteConfigs - ]) - } + checkout scm +} From ea4fc4fb8d5b98ce9e5a65e5f350f6bf30bd397b Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Wed, 22 Nov 2017 21:38:52 +0530 Subject: [PATCH 5/9] Update Jenkinsfile --- Jenkinsfile | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7202c9..448b537 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,43 @@ -node { - checkout scm -} +#!groovy + +node('node') { + + + currentBuild.result = "SUCCESS" + + try { + + stage('Checkout'){ + + checkout scm + } + + + + stage('mail'){ + + + mail body: 'project build successful', + from: 'devopstrainingblr@gmail.com', + replyTo: 'mithunreddytechnologies@gmail.com', + subject: 'project build successful', + to: 'mithunreddytechnologies@gmail.com' + } + + + + } + catch (err) { + + currentBuild.result = "FAILURE" + + mail body: "project build error is here: ${env.BUILD_URL}" , + from: 'devopstrainingblr@gmail.com', + replyTo: 'mithunreddytechnologies@gmail.com', + subject: 'project build failed', + to: 'mithunreddytechnologies@gmail.com' + + throw err + } + + From 69417fa732da10e68e5fb9a6ec45357537330502 Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Wed, 22 Nov 2017 21:45:57 +0530 Subject: [PATCH 6/9] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 448b537..640167c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,5 +39,6 @@ node('node') { throw err } +} From 3f08895e5c21cacb7f8409edea9eb2335494a9e2 Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Wed, 22 Nov 2017 21:48:27 +0530 Subject: [PATCH 7/9] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 640167c..4a47d6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ #!groovy -node('node') { +node { currentBuild.result = "SUCCESS" From 679a3cb83f47fadafab088b4652f9ce6083b694b Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Wed, 22 Nov 2017 22:00:36 +0530 Subject: [PATCH 8/9] Update Jenkinsfile --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4a47d6d..bcc508d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,11 @@ node { checkout scm } - + stage('Sonar') { + //add stage sonar + sh 'mvn sonar:sonar' + } + stage('mail'){ From 0d8a8e16993d6d182e1337a897d5426e7ae64bcf Mon Sep 17 00:00:00 2001 From: DevOps Training Date: Tue, 28 Nov 2017 07:58:38 +0530 Subject: [PATCH 9/9] Update Jenkinsfile --- Jenkinsfile | 57 +++++++++++------------------------------------------ 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bcc508d..3a67e91 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,48 +1,13 @@ -#!groovy - +stage 'Init' node { - - - currentBuild.result = "SUCCESS" - - try { - - stage('Checkout'){ - - checkout scm - } - - stage('Sonar') { - //add stage sonar - sh 'mvn sonar:sonar' - } - - - stage('mail'){ - - - mail body: 'project build successful', - from: 'devopstrainingblr@gmail.com', - replyTo: 'mithunreddytechnologies@gmail.com', - subject: 'project build successful', - to: 'mithunreddytechnologies@gmail.com' - } - - - - } - catch (err) { - - currentBuild.result = "FAILURE" - - mail body: "project build error is here: ${env.BUILD_URL}" , - from: 'devopstrainingblr@gmail.com', - replyTo: 'mithunreddytechnologies@gmail.com', - subject: 'project build failed', - to: 'mithunreddytechnologies@gmail.com' - - throw err - } -} - + checkout scm + sh 'echo $BRANCH_NAME' +} +if (env.BRANCH_NAME == 'master') { + stage 'Only on master' + println 'This happens only on master' +} else { + stage 'Other branches' + println "Current branch ${env.BRANCH_NAME}" +}