From 4e07c7deaf3850cb8d679419acb5c5019d092c88 Mon Sep 17 00:00:00 2001 From: Chris Bynum <chris.bynum@levvel.io> Date: Wed, 3 Aug 2016 23:40:48 -0400 Subject: [PATCH] Use scripts from /bin within pipeline. --- Jenkinsfile | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 199ad6b..1870b14 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,19 +3,40 @@ node { checkout scm - stage 'Base' - - sh './build_image.sh' - - stage 'Tests' - + stage 'BUILD: Base' + + try{ + // Build Base Image + dir('bin') { + sh './build.sh &> debug' + } + // Build Base Image + // sh './build_image.sh &> debug' + // Run Base Container + // sh 'bin/run.sh' + } catch(error) { + def error_details = readFile('./bin/debug'); + def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}" + sh "rm -f ./bin/debug" + handleError(message) + } + + stage 'TEST: Base' + sh '/usr/local/bin/bats tests/base.bats' - - stage 'Push' - + + stage 'SHIP: Base' + docker.withRegistry('https://registry.hub.docker.com/', 'dockerhub-bigfleet') { def baseImg = docker.build('bigfleet/centos7base') baseImg.push('latest') } +} -} \ No newline at end of file +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]) + sh 'exit 1' +}