From f9c0c7bcb0e639a3a482a9baec1e28d5b3c68334 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Tue, 30 Aug 2016 10:15:23 -0400 Subject: [PATCH] Updated base build --- Jenkinsfile | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cc9cb47..555d40f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,26 +2,58 @@ node { stage 'Checkout' checkout scm + + stage 'Acquire util' + + sh 'mkdir -p tmp' + dir('tmp'){ + git([ url: "https://github.internet2.edu/docker/util.git", + credentialsId: "jenkins-github-access-token" ]) + sh 'ls' + sh 'mv ./bin/* ../bin/.' + } + stage 'Setting build context' + + def maintainer = maintainer() + def imagename = imagename() + def tag + + // Tag images created on master branch with 'latest' + if(env.BRANCH_NAME == "master"){ + tag = "latest" + }else{ + tag = env.BRANCH_NAME + } + + if(!imagename){ + echo "You must define an imagename in common.bash" + currentBuild.result = 'FAILURE' + } + if(maintainer){ + echo "Building ${maintainer}:${tag} for ${maintainer}" + } stage 'BUILD: Base' try{ - // Build Base Image - sh './build.sh &> debug' - // Build Base Image - // sh './build_image.sh &> debug' - // Run Base Container - // sh 'bin/run.sh' + sh 'bin/build.sh &> debug' } catch(error) { def error_details = readFile('./debug'); - def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}" + def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" sh "rm -f ./debug" handleError(message) } stage 'TEST: Base' - sh 'bats tests/base.bats' + try{ + sh 'bin/test.sh &> debug' + } catch(error) { + def error_details = readFile('./debug'); + def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } stage 'SHIP: Base' @@ -35,6 +67,6 @@ def handleError(String message){ echo "${message}" currentBuild.setResult("FAILED") slackSend color: 'danger', message: "${message}" - step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true]) + #step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true]) sh 'exit 1' }