From 91c611f8aa3c172896b5f17009c56b60e6639dac Mon Sep 17 00:00:00 2001 From: Christopher Hubing <chubing@internet2.edu> Date: Mon, 8 Oct 2018 12:41:05 -0400 Subject: [PATCH] Update Jenkinsfile --- Jenkinsfile | 55 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fb2ba008..0d52ba13 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,24 +46,51 @@ pipeline { } } stage('Build') { + steps { + script { + try{ + sh 'bin/rebuild.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('Test') { + steps { + script { + try { + sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0' + } catch (error) { + def error_details = readFile('./debug') + def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } + } + } + + stage('Push') { steps { script { docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { def baseImg = docker.build("$maintainer/$imagename", "--no-cache .") - // scan the image with clair - sh 'docker run -p 5432:5432 -d --name clairdb arminc/clair-db:latest' - sh 'docker run -p 6060:6060 --link clairdb:postgres -d --name clair arminc/clair-local-scan:v2.0.5' - sh 'curl -L -o clair-scanner https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64' - sh 'chmod 755 clair-scanner' - sh "./clair-scanner --ip 172.17.0.1 -r test.out $maintainer/$imagename:latest" - // test the environment - sh 'docker kill clairdb' - sh 'docker rm clairdb' - sh 'docker kill clair' - sh 'docker rm clair' - sh 'cd test-compose && ./compose.sh' - // bring down after testing - sh 'cd test-compose && docker-compose down' + //// scan the image with clair + // sh 'docker run -p 5432:5432 -d --name clairdb arminc/clair-db:latest' + // sh 'docker run -p 6060:6060 --link clairdb:postgres -d --name clair arminc/clair-local-scan:v2.0.5' + // sh 'curl -L -o clair-scanner https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64' + // sh 'chmod 755 clair-scanner' + // sh "./clair-scanner --ip 172.17.0.1 -r test.out $maintainer/$imagename:latest" + //// test the environment + // sh 'docker kill clairdb' + // sh 'docker rm clairdb' + // sh 'docker kill clair' + // sh 'docker rm clair' + // sh 'cd test-compose && ./compose.sh' + //// bring down after testing + //sh 'cd test-compose && docker-compose down' baseImg.push("$tag") }