diff --git a/Dockerfile b/Dockerfile index a567e14..0e384a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,8 @@ RUN yum -y install \ && rm /etc/httpd/conf.d/userdir.conf \ && rm /etc/httpd/conf.d/welcome.conf +ONBUILD COPY ./certs/ /etc/httpd/certs/ +ONBUILD COPY ./conf/ /etc/httpd/conf.d/ COPY httpd-foreground /usr/local/bin/ diff --git a/Jenkinsfile b/Jenkinsfile index 92b3cad..9c5c080 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,11 +27,19 @@ node('docker') { echo "Building ${maintainer}:${tag} for ${maintainer}" } - sh 'bin/rebuild.sh' + try{ + // Build Base Image + sh 'bin/rebuild.sh &> debug' + } catch(error) { + def error_details = readFile('./debug'); + def message = "BUILD ERROR: There was a problem building ${imagename}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } stage 'Start container' - sh 'bin/ci-run.sh && sleep 60' + sh 'bin/ci-run.sh' stage 'Tests' @@ -59,4 +67,12 @@ def maintainer() { def imagename() { def matcher = readFile('common.bash') =~ 'imagename="(.+)"' matcher ? matcher[0][1] : null +} + +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' } \ No newline at end of file diff --git a/bin/ci-run.sh b/bin/ci-run.sh index 70761f0..80b6c0d 100755 --- a/bin/ci-run.sh +++ b/bin/ci-run.sh @@ -3,4 +3,4 @@ # This file will run a container in the background source common.bash . -docker run -d --name=$imagename -p 80:80 -p 443:443 $maintainer/$imagename \ No newline at end of file +docker run -d --name=$imagename -p 80:80 -p 443:443 $maintainer/$imagename diff --git a/bin/ci-stop.sh b/bin/ci-stop.sh index 2ac6a32..416db9e 100755 --- a/bin/ci-stop.sh +++ b/bin/ci-stop.sh @@ -5,5 +5,4 @@ source common.bash . echo "Cleaning up Docker image($maintainer/$imagename)" docker stop $imagename >> /dev/null -docker rm $imagename -exit 0 \ No newline at end of file +docker rm $imagename \ No newline at end of file diff --git a/tests/image.bats b/tests/image.bats index b52fe41..bbff398 100755 --- a/tests/image.bats +++ b/tests/image.bats @@ -5,4 +5,8 @@ load ../common @test "Concludes first-run experience" { result="$(docker run -i $maintainer/$imagename find /tmp/firsttimerunning)" [ "$result" != '' ] +} + +@test "Contains ONBUILD mechanism" { + grep ONBUILD Dockerfile } \ No newline at end of file