From 65853036fa83617e1abebbba40a19f02341693fd Mon Sep 17 00:00:00 2001 From: Christopher Hubing Date: Mon, 30 Apr 2018 16:56:37 -0400 Subject: [PATCH 1/3] Create Jenkinsfile --- Jenkinsfile | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1369868 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,77 @@ + +pipeline { + agent any + environment { + maintainer = "t" + imagename = 'r' + tag = 'l' + } + stages { + stage('Setting build context') { + steps { + script { + maintainer = maintain() + imagename = imagename() + 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' + } + } + } + } + stage('Build') { + steps { + echo 'step 2' + } + } + stage('Push') { + steps { + script { + docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { + def baseImg = docker.build("$maintainer/$imagename", "--no-cache .") + baseImg.push("$tag") + } + } + } + } + stage('Notify') { + steps{ + echo "$maintainer" + slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" + } + } + } + post { + always { + echo 'Post process.' + } + failure { + // slackSend color: 'good', message: "Build failed" + handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag}.") + } + } +} + + +def maintain() { + def matcher = readFile('common.bash') =~ 'maintainer="(.+)"' + matcher ? matcher[0][1] : 'tier' +} + +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: 'chubing@internet2.edu', sendToIndividuals: true]) + sh 'exit 1' +} From 752da635487918311863faed8c1a5a9ea190a6c0 Mon Sep 17 00:00:00 2001 From: Christopher Hubing Date: Mon, 30 Apr 2018 16:57:00 -0400 Subject: [PATCH 2/3] Create common.bash --- common.bash | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 common.bash diff --git a/common.bash b/common.bash new file mode 100644 index 0000000..a8c5bcc --- /dev/null +++ b/common.bash @@ -0,0 +1,2 @@ +maintainer="tier" +imagename="rabbitmq" From efbc7ef947417b55549a32f7303260b30308020b Mon Sep 17 00:00:00 2001 From: Christopher Hubing Date: Mon, 30 Apr 2018 17:05:16 -0400 Subject: [PATCH 3/3] Update Dockerfile --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74fcd3d..db5c7f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,10 @@ ENV RABBITMQ_LOGS=- RABBITMQ_SASL_LOGS=- RUN /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management RUN /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_tracing RUN sed -i s/'%% {load_definitions, .*"},'/'{load_definitions, "\/etc\/rabbitmq\/rabbitmq.json"}'/ /etc/rabbitmq/rabbitmq.config -ENV JAVA_VERSION=8u162 -ENV BUILD_VERSION=b12 -ENV JAVA_BUNDLE_ID=0da788060d494f5095bf8624735fa2f1 + +ENV JAVA_VERSION=8u171 +ENV BUILD_VERSION=b11 +ENV JAVA_BUNDLE_ID=512cd62ec5174c3487ac17c61aaa89e8 # ==> By uncommenting these next 6 lines, you agree to the Oracle Binary Code License Agreement for Java SE (http://www.oracle.com/technetwork/java/javase/terms/license/index.html) RUN wget -nv --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/$JAVA_BUNDLE_ID/jdk-$JAVA_VERSION-linux-x64.rpm" -O /tmp/jdk-$JAVA_VERSION-$BUILD_VERSION-linux-x64.rpm && \ yum -y install /tmp/jdk-$JAVA_VERSION-$BUILD_VERSION-linux-x64.rpm && \