diff --git a/Dockerfile b/Dockerfile index 790d59d..c0b2345 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,12 @@ FROM tier/shibboleth_sp # Define args and set a default value ARG maintainer=tier -ARG imagename=siteadmin-www +ARG imagename=siteadmin-sp ARG version=1.0 MAINTAINER $maintainer LABEL Vendor="Internet2" -LABEL ImageType="WWW" +LABEL ImageType="SP" LABEL ImageName=$imagename LABEL ImageOS=centos7 LABEL Version=$version diff --git a/Jenkinsfile b/Jenkinsfile index c4b3931..28517cb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -node { +node('docker') { stage 'Checkout' @@ -42,19 +42,27 @@ node { 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) + handleError(message, tag) } + stage 'Start container' + + sh 'bin/ci-run.sh && sleep 15' + stage 'Tests' - + 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}" + def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}" sh "rm -f ./debug" - handleError(message) + handleError(message, tag) } + + stage 'Stop container' + + sh 'bin/ci-stop.sh' stage 'Push' @@ -63,6 +71,10 @@ node { baseImg.push("$tag") } + stage 'Clean Up' + + cleanup(tag) + stage 'Notify' slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" @@ -79,10 +91,24 @@ def imagename() { matcher ? matcher[0][1] : null } -def handleError(String message){ +def handleError(String message, String tag, Boolean doCleanup = true){ echo "${message}" currentBuild.setResult("FAILED") slackSend color: 'danger', message: "${message}" //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true]) + if (doCleanup) { + cleanup(tag) + } sh 'exit 1' +} + +def cleanup(String tag) { + try{ + sh 'bin/destroy.sh &> debug' + } catch(error) { + def error_details = readFile('./debug'); + def message = "BUILD ERROR: There was a problem cleaning up ${imagename}:${tag}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message, tag, false) + } } \ No newline at end of file diff --git a/common.bash b/common.bash index 513e3b6..976e3ae 100644 --- a/common.bash +++ b/common.bash @@ -1,2 +1,2 @@ maintainer="tier" -imagename="siteadmin-www" \ No newline at end of file +imagename="siteadmin-sp" \ No newline at end of file