diff --git a/.gitignore b/.gitignore index 7234e2c9..af52e969 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bin/* dist/* reports/* docs/* +Jenkinsfile_01 diff --git a/Jenkinsfile b/Jenkinsfile index 9bf770a7..c0e5850b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,23 +1,167 @@ pipeline { - agent any + + agent none + + + environment{ + + MAJOR_VERSION=1 + + } + stages { stage('Unit Tests') { + + agent{ + label 'apache' + } + steps { + + sh 'ant -f test.xml -v' + // junit 'reports/result.xml' + } } stage('build') { + + agent{ + + label 'apache' + + } + steps { sh 'ant -f build.xml -v' } + + post { + success { + + archiveArtifacts artifacts: 'dist/*.jar', fingerprint: true + + } + } + + } + + stage('deploy'){ + + agent{ + label 'apache' + } + + steps{ + sh "mkdir -p /var/www/html/rectangles/all/${env.BRANCH_NAME}" + sh "cp dist/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/all/${env.BRANCH_NAME}" + } + + } + + + stage('functional check on debian'){ + + agent{ + label 'agentOne' + } + + steps{ + sh "wget http://35.230.114.105/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar" + sh "java -jar rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar 54 321" + } + } + + stage('promote to green' ){ + + agent{ + label 'apache' + } + + when{ + branch 'Amar02' + } + + steps{ + + sh "cp /var/www/html/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/green" + + } + } + + + + // Added this stage for automatic branch promotions ... + stage('Promote Amar03 to Amar02'){ + + agent{ + label 'apache' + } + + + + when { + branch 'Amar03' + } + + steps{ + echo "Stashing any local changes.." + sh "git stash" + echo "Checking Out Amar03" + sh "git checkout Amar03" + sh "git pull" + echo "Checking Out Amar02" + sh "git checkout Amar02" + echo "Merging Amar03" + sh "git merge Amar03" + echo "Pushing to Origin Amar02" + sh 'git push origin Amar02' + echo 'NO PROBLEMS 23' + sh "git tag -a ${env.MAJOR_VERSION}.${env.BUILD_NUMBER} -m ${env.GIT_COMMIT}" + sh "git push origin ${env.MAJOR_VERSION}.${env.BUILD_NUMBER}" + } + + post{ + success{ + emailext(subject:"SUCCESSFUL Amar03 Promoted to Amar02 : Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: """
SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':
+Check console output at "${env.JOB_NAME} [${env.BUILD_NUMBER}]"
""", + + to:"srinuamar9@gmail.com") + } + + failure{ + emailext (subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: """FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':
+Check console output at "${env.JOB_NAME} [${env.BUILD_NUMBER}]"
""", + to:"srinuamar9@gmail.com") + } + + + } + + } + + } - post { - always { - archiveArtifacts artifacts: 'dist/*.jar', fingerprint: true + + post{ + + always{ + + emailext(subject:"ENTER THE PROJECT ${env.JOB_NAME} BUILD ${env.BUILD_NUMBER}", + body: "FIND THE LOG HERE ${env.BUILD_URL}", + to:"srinuamar9@gmail.com") + } + + } + + + } diff --git a/Jenkinsfile0 b/Jenkinsfile0 new file mode 100644 index 00000000..4766cb39 --- /dev/null +++ b/Jenkinsfile0 @@ -0,0 +1,94 @@ +pipeline { + + agent none + + stages { + stage('Unit Tests') { + + agent{ + label 'apache' + } + steps { + sh 'ant -f test.xml -v' + junit 'reports/result.xml' + } + } + stage('build') { + + agent{ + label 'apache' + } + + steps { + sh 'ant -f build.xml -v' + } + + post { + success { + archiveArtifacts artifacts: 'dist/*.jar', fingerprint: true + } + } + + + } + + stage('deploy'){ + + agent{ + label 'apache' + } + + steps{ + sh "cp dist/rectangle_${env.BUILD_NUMBER}.jar /var/www/html/rectangles/all/" + } + + } + + + + + stage('functional check on docker debian'){ + + agent{ + docker 'openjdk:8u151-jre' + } + + steps{ + sh "wget http://srinuamar91.mylabserver.com/rectangles/all/rectangle_${env.BUILD_NUMBER}.jar" + sh "java -jar rectangle_${env.BUILD_NUMBER}.jar 54 321" + } + + + } + + stage('functional check on centos'){ + + agent{ + label 'centos' + } + + steps{ + sh "wget http://srinuamar91.mylabserver.com/rectangles/all/rectangle_${env.BUILD_NUMBER}.jar" + sh "java -jar rectangle_${env.BUILD_NUMBER}.jar 54 321" + } + } + + stage('promote to green' ){ + + agent{ + label 'apache' + } + + steps{ + + sh "cp /var/www/html/rectangles/all/rectangle_${env.BUILD_NUMBER}.jar /var/www/html/rectangles/green" + + } + } + + + } + + + +} diff --git a/Jenkinsfile_01 b/Jenkinsfile_01 new file mode 100644 index 00000000..f6c3142a --- /dev/null +++ b/Jenkinsfile_01 @@ -0,0 +1,50 @@ +pipeline{ + agent none + + environment{ + + ENV_VAR='some_value' + + } + + stages{ + stage('build'){ + agent{ + label 'centos' + } + steps{ + echo 'building..' + } + stage('test'){ + agent docker + agent{ + docker 'openjdk:8u121-jre' + } + + steps{ + echo 'testing...' + } + } + + + + + + stage('deploy'){ + steps{ + echo 'deploying...' + } + } + } + + + post{ + + always{ + + archive 'dist/*.jar' + } + + } + +} diff --git a/build.xml b/build.xml index 8e7c08e7..8576eabf 100644 --- a/build.xml +++ b/build.xml @@ -34,7 +34,7 @@