From 02a89c8270d4a4e17c8437c3b639d9c5c14f16a9 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:01:06 +0530 Subject: [PATCH 01/17] Added new file --- Jenkinsfile | 76 +++++++++++------------------------------------------ 1 file changed, 16 insertions(+), 60 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 81748a7..cf5ad76 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,74 +1,30 @@ -pipeline { +pipeline{ agent any - - environment { + environment{ MAJOR_VERSION = 1 } - - stages { - stage('build') { - steps { + stages{ + stage('compile') { + steps{ sh 'javac -d . src/*.java' sh 'echo Main-Class: Rectangulator > MANIFEST.MF' sh 'jar -cvmf MANIFEST.MF rectangle.jar *.class' } - post { - success { - archiveArtifacts artifacts: 'rectangle.jar', fingerprint: true - } - } } stage('run') { - steps { - sh 'java -jar rectangle.jar 7 9' - } - } - stage('Promote Development to Master') { - when { - branch 'development' - } - steps { - echo "Stashing Local Changes" - sh "git stash" - echo "Checking Out Development" - sh 'git checkout development' - sh 'git pull origin' - echo 'Checking Out Master' - sh 'git checkout master' - echo "Merging Development into Master" - sh 'git merge development' - echo "Git Push to Origin" - sh 'git push origin master' - } - post { - success { - emailext( - subject: "${env.JOB_NAME} [${env.BUILD_NUMBER}] Development Promoted to Master", - body: """

'${env.JOB_NAME} [${env.BUILD_NUMBER}]' Development Promoted to Master":

-

Check console output at ${env.JOB_NAME} [${env.BUILD_NUMBER}]

""", - to: "brandon@linuxacademy.com" - ) - } + steps{ + sh 'java -jar rectangle.jar 3 4' } } - stage('Tagging the Release') { - when { - branch 'master' - } - steps { - sh "git tag rectangle-${env.MAJOR_VERSION}.${BUILD_NUMBER}" - sh "git push origin rectangle-${env.MAJOR_VERSION}.${BUILD_NUMBER}" - } - post { - success { - emailext( - subject: "${env.JOB_NAME} [${env.BUILD_NUMBER}] NEW RELEASE", - body: """

'${env.JOB_NAME} [${env.BUILD_NUMBER}]' NEW RELEASE":

-

Check console output at ${env.JOB_NAME} [${env.BUILD_NUMBER}]

""", - to: "brandon@linuxacademy.com" - ) - } - } + } + post{ + success{ + archiveArtifacts: artifact rectangle.jar, fingerprint: true + emailext( + subject: 'Build Success ${env.$BUILD_NUMBER}', + body: 'More information of Build ${env.$BUILD_NUMBER}: \n at ${env.$BUILD_URL}', + to: 'praveen.kumar@avizva.com' + ) } } } From 9483b1dee56e4f10b8496149577b0316481f4fc5 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:08:28 +0530 Subject: [PATCH 02/17] Added varialbes --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cf5ad76..58fcace 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,8 +21,8 @@ pipeline{ success{ archiveArtifacts: artifact rectangle.jar, fingerprint: true emailext( - subject: 'Build Success ${env.$BUILD_NUMBER}', - body: 'More information of Build ${env.$BUILD_NUMBER}: \n at ${env.$BUILD_URL}', + subject: 'Build Success ${env.${BUILD_NUMBER}}', + body: 'More information of Build ${env.${BUILD_NUMBER}}: \n at ${env.${BUILD_URL}}', to: 'praveen.kumar@avizva.com' ) } From 41a80995dfa06827157653dfd849ba21f9210082 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:11:44 +0530 Subject: [PATCH 03/17] syntax error fixed --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 58fcace..c31ba17 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,10 +19,10 @@ pipeline{ } post{ success{ - archiveArtifacts: artifact rectangle.jar, fingerprint: true + archiveArtifacts artifacts: rectangle.jar, fingerprint: true emailext( - subject: 'Build Success ${env.${BUILD_NUMBER}}', - body: 'More information of Build ${env.${BUILD_NUMBER}}: \n at ${env.${BUILD_URL}}', + subject: 'Build Success ${env.$BUILD_NUMBER}', + body: 'More information of Build ${env.$BUILD_NUMBER}: \n at ${env.$BUILD_URL}', to: 'praveen.kumar@avizva.com' ) } From d64fde502be6b619d79f992996f8c9be18ccd7ad Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:13:50 +0530 Subject: [PATCH 04/17] fixed error --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c31ba17..7313384 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,7 @@ pipeline{ } post{ success{ - archiveArtifacts artifacts: rectangle.jar, fingerprint: true + archiveArtifacts artifacts: 'rectangle.jar', fingerprint: true emailext( subject: 'Build Success ${env.$BUILD_NUMBER}', body: 'More information of Build ${env.$BUILD_NUMBER}: \n at ${env.$BUILD_URL}', From 644b10747ac079a29e9ec1050ec57d99571fc1af Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:15:07 +0530 Subject: [PATCH 05/17] test commit --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7313384..2905e71 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,8 +21,8 @@ pipeline{ success{ archiveArtifacts artifacts: 'rectangle.jar', fingerprint: true emailext( - subject: 'Build Success ${env.$BUILD_NUMBER}', - body: 'More information of Build ${env.$BUILD_NUMBER}: \n at ${env.$BUILD_URL}', + subject: 'Build Success ${BUILD_NUMBER}', + body: 'More information of Build ${BUILD_NUMBER}: \n at ${BUILD_URL}', to: 'praveen.kumar@avizva.com' ) } From 9aa6650fde1de3e129463628cd5fe2f22d438476 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:21:31 +0530 Subject: [PATCH 06/17] added major version --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2905e71..6f07a71 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,21 +8,21 @@ pipeline{ steps{ sh 'javac -d . src/*.java' sh 'echo Main-Class: Rectangulator > MANIFEST.MF' - sh 'jar -cvmf MANIFEST.MF rectangle.jar *.class' + sh 'jar -cvmf MANIFEST.MF rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar *.class' } } stage('run') { steps{ - sh 'java -jar rectangle.jar 3 4' + sh 'java -jar rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar 3 4' } } } post{ success{ - archiveArtifacts artifacts: 'rectangle.jar', fingerprint: true + archiveArtifacts artifacts: 'rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar', fingerprint: true emailext( - subject: 'Build Success ${BUILD_NUMBER}', - body: 'More information of Build ${BUILD_NUMBER}: \n at ${BUILD_URL}', + subject: 'Build Success ${env.BUILD_NUMBER}', + body: 'More information of Build ${env.BUILD_NUMBER}: \n at ${env.BUILD_URL}', to: 'praveen.kumar@avizva.com' ) } From 5f5105deb38247b326bf4a36538384925215034f Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:24:51 +0530 Subject: [PATCH 07/17] test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6f07a71..39623c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline{ } stage('run') { steps{ - sh 'java -jar rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar 3 4' + sh 'java -jar rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}.jar 3 4' } } } From 484125515e163779177455f7aeb90905d84300f2 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:26:11 +0530 Subject: [PATCH 08/17] test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 39623c5..7e4e71f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline{ steps{ sh 'javac -d . src/*.java' sh 'echo Main-Class: Rectangulator > MANIFEST.MF' - sh 'jar -cvmf MANIFEST.MF rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar *.class' + sh 'jar -cvmf MANIFEST.MF rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}.jar *.class' } } stage('run') { From add3cabca053e15240b3a84e5decd5b85fba82d6 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:27:32 +0530 Subject: [PATCH 09/17] fixed issues related to variables --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7e4e71f..4b3f44f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,10 +19,10 @@ pipeline{ } post{ success{ - archiveArtifacts artifacts: 'rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar', fingerprint: true + archiveArtifacts artifacts: 'rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}.jar', fingerprint: true emailext( - subject: 'Build Success ${env.BUILD_NUMBER}', - body: 'More information of Build ${env.BUILD_NUMBER}: \n at ${env.BUILD_URL}', + subject: 'Build Success ${BUILD_NUMBER}', + body: 'More information of Build ${BUILD_NUMBER}: \n at ${BUILD_URL}', to: 'praveen.kumar@avizva.com' ) } From 9190888b756701dc4034b3502f24adbb6572500b Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 18:31:08 +0530 Subject: [PATCH 10/17] test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4b3f44f..0b61169 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,7 @@ pipeline{ } post{ success{ - archiveArtifacts artifacts: 'rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}.jar', fingerprint: true + archiveArtifacts artifacts: "rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}.jar", fingerprint: true emailext( subject: 'Build Success ${BUILD_NUMBER}', body: 'More information of Build ${BUILD_NUMBER}: \n at ${BUILD_URL}', From fd1aa38bd812e597026a75650890cf091e8734b2 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 19:20:02 +0530 Subject: [PATCH 11/17] Code Promotion --- Jenkinsfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0b61169..95f777e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,6 +16,28 @@ pipeline{ sh 'java -jar rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}.jar 3 4' } } + stage('code promotion'){ + when{ + branch 'development' + } + steps{ + echo 'Stashing git changes' + sh 'git stash' + echo 'Checkout development branch' + sh 'git checkout development' + echo 'Pull the changes' + sh 'git pull origin' + echo 'Checkout master branch' + sh 'git checkout master' + echo 'merging the changes' + sh 'git merge development' + echo 'Push the changes to master' + sh 'git push origin master' + echo 'Tagging the release' + sh 'git tag rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}' + sh 'git push origin rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}' + } + } } post{ success{ From 2032bcbffa0b31bc699e6a6fa6e915e115a6b12b Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 19:22:25 +0530 Subject: [PATCH 12/17] Added pull master --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 95f777e..ed1cc6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,6 +29,8 @@ pipeline{ sh 'git pull origin' echo 'Checkout master branch' sh 'git checkout master' + echo 'Pull latest changes master branch' + sh 'git pull origin' echo 'merging the changes' sh 'git merge development' echo 'Push the changes to master' From 54e9b2710ada69a27204d47c807de2ccd1952c89 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 19:38:51 +0530 Subject: [PATCH 13/17] commit --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index ed1cc6d..336fdaf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,6 +31,8 @@ pipeline{ sh 'git checkout master' echo 'Pull latest changes master branch' sh 'git pull origin' + sh "git config --global user.email "praveen.sbb@gmail.com"" + sh "git config --global user.name "prvnkmr484"" echo 'merging the changes' sh 'git merge development' echo 'Push the changes to master' From 36227b8ae0389ecf852294e70445043688cf4bcd Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 19:41:22 +0530 Subject: [PATCH 14/17] committed git config --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 336fdaf..8823f41 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,8 +31,8 @@ pipeline{ sh 'git checkout master' echo 'Pull latest changes master branch' sh 'git pull origin' - sh "git config --global user.email "praveen.sbb@gmail.com"" - sh "git config --global user.name "prvnkmr484"" + sh 'git config --global user.email praveen.sbb@gmail.com' + sh 'git config --global user.name prvnkmr484' echo 'merging the changes' sh 'git merge development' echo 'Push the changes to master' From ea3fb1ed6d887af188f956c7ecfc943c45206a60 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 19:42:37 +0530 Subject: [PATCH 15/17] updated git config --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8823f41..91acb53 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,9 +30,9 @@ pipeline{ echo 'Checkout master branch' sh 'git checkout master' echo 'Pull latest changes master branch' + sh 'git config user.email praveen.sbb@gmail.com' + sh 'git config user.name prvnkmr484' sh 'git pull origin' - sh 'git config --global user.email praveen.sbb@gmail.com' - sh 'git config --global user.name prvnkmr484' echo 'merging the changes' sh 'git merge development' echo 'Push the changes to master' From e6214da6dfb9caffaf4f8ebed3c4487d276bea36 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 19:44:54 +0530 Subject: [PATCH 16/17] commit --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 91acb53..7a9fa9d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,7 +32,7 @@ pipeline{ echo 'Pull latest changes master branch' sh 'git config user.email praveen.sbb@gmail.com' sh 'git config user.name prvnkmr484' - sh 'git pull origin' + sh 'git pull origin master' echo 'merging the changes' sh 'git merge development' echo 'Push the changes to master' From e868f6c51e07dc46943af4795292c49617733951 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 21 Oct 2017 19:52:27 +0530 Subject: [PATCH 17/17] seperated git tagging --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7a9fa9d..472e5d5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,11 +32,15 @@ pipeline{ echo 'Pull latest changes master branch' sh 'git config user.email praveen.sbb@gmail.com' sh 'git config user.name prvnkmr484' - sh 'git pull origin master' + sh 'git pull origin' echo 'merging the changes' sh 'git merge development' echo 'Push the changes to master' sh 'git push origin master' + } + } + stage('Git Tagging'){ + steps{ echo 'Tagging the release' sh 'git tag rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}' sh 'git push origin rectangle_${MAJOR_VERSION}.${BUILD_NUMBER}'