diff --git a/Jenkinsfile b/Jenkinsfile index 3fec481e..56508ba9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,134 +1,90 @@ pipeline { agent none - - environment { - MAJOR_VERSION = 1 - } - stages { - stage('Say Hello') { - agent any - - steps { - sayHello 'Awesome Student!' - } - } - stage('Git Information') { - agent any - - steps { - echo "My Branch Name: ${env.BRANCH_NAME}" - - script { - def myLib = new linuxacademy.git.gitStuff(); - - echo "My Commit: ${myLib.gitCommit("${env.WORKSPACE}/.git")}" - } - } - } - stage('Unit Tests') { + stage ('Unit Tests') { agent { - label 'apache' + label 'apache' } steps { - sh 'ant -f test.xml -v' + sh 'ant -f test.xml -v' junit 'reports/result.xml' } } - stage('build') { + stage ('build') { agent { - label 'apache' + label 'apache' } - steps { + steps{ sh 'ant -f build.xml -v' } post { - success { - archiveArtifacts artifacts: 'dist/*.jar', fingerprint: true - } - } - } - stage('deploy') { + success { + archiveArtifacts artifacts: 'dist/*.jar', fingerprint: true + } +} + } + stage ('deploy'){ agent { - label 'apache' + label 'apache' } steps { - sh "if ![ -d '/var/www/html/rectangles/all/${env.BRANCH_NAME}' ]; then mkdir /var/www/html/rectangles/all/${env.BRANCH_NAME}; fi" - sh "cp dist/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/all/${env.BRANCH_NAME}/" + sh "mkdir /var/www/html/rectangles/all/${env.BRANCH_NAME}" + sh "cp dist/rectangle_${env.BUILD_NUMBER}.jar /var/www/html/rectangles/all/${env.BRANCH_NAME}/" } } - stage("Running on CentOS") { + stage ('Running on CentOs'){ agent { - label 'CentOS' + label 'CentOs' } steps { - sh "wget http://brandon4231.mylabserver.com/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar" - sh "java -jar rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar 3 4" + sh "wget http://cprakas011d.mylabserver.com/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.BUILD_NUMBER}.jar" + sh "java -jar rectangle_${env.BUILD_NUMBER}.jar 3 4" } } - stage("Test on Debian") { - agent { - docker 'openjdk:8u121-jre' - } - steps { - sh "wget http://brandon4231.mylabserver.com/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar" - sh "java -jar rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar 3 4" - } + stage ('Ruuning on debian'){ + agent { + docker 'openjdk:8u121-jre' + } + steps { + sh "wget http://cprakas011d.mylabserver.com/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.BUILD_NUMBER}.jar" + sh "java -jar rectangle_${env.BUILD_NUMBER}.jar 3 4" } - stage('Promote to Green') { + } + stage('Promote to green'){ agent { - label 'apache' + label 'apache' } when { - branch 'master' + branch 'master' } steps { - sh "cp /var/www/html/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/green/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar" + sh "cp /var/www/html/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.BUILD_NUMBER}.jar /var/www/html/rectangles/green/" } } - stage('Promote Development Branch to Master') { - agent { - label 'apache' + stage('Promote developement to master'){ + agent { + label 'apache' } when { - branch 'development' + branch 'developement' } steps { - echo "Stashing Any Local Changes" + echo "Stash any local changes" sh 'git stash' - echo "Checking Out Development Branch" - sh 'git checkout development' - echo 'Checking Out Master Branch' - sh 'git pull origin' + echo "Checking out developement branch" + sh 'git checkout developement' + sh 'git pull' + echo "Checking out the master" sh 'git checkout master' - echo 'Merging Development into Master Branch' - sh 'git merge development' - echo 'Pushing to Origin Master' + sh 'git pull' + echo 'Merging developement to master' + sh 'git merge developement' + echo "Pusing to origin master" + sh "git remote set-url origin git@github.com:temtestuser/content-jenkins-java-project.git" sh 'git push origin master' - echo 'Tagging the Release' - sh "git tag rectangle-${env.MAJOR_VERSION}.${env.BUILD_NUMBER}" - sh "git push origin rectangle-${env.MAJOR_VERSION}.${env.BUILD_NUMBER}" - } - 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" - ) - } + echo "T" + echo "Hi" } } } - post { - failure { - emailext( - subject: "${env.JOB_NAME} [${env.BUILD_NUMBER}] Failed!", - body: """'${env.JOB_NAME} [${env.BUILD_NUMBER}]' Failed!":
-Check console output at "${env.JOB_NAME} [${env.BUILD_NUMBER}]"
""", - to: "brandon@linuxacademy.com" - ) - } - } -} + } diff --git a/build.xml b/build.xml index 8576eabf..062d7c5b 100644 --- a/build.xml +++ b/build.xml @@ -34,7 +34,7 @@