From c3c0b7de3e14f664f49f287cbfdcf482eca9d1ff Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Apr 27 2017 06:09:00 +0000 Subject: [PATCH 1/3] Jenkinsfile: do mock builds in parallel --- diff --git a/Jenkinsfile b/Jenkinsfile index d10da3e..c2ff27b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,20 +22,24 @@ node('rcm-tools-jslave-rhel-7') { /* We take a flock on the mock configs, to avoid multiple unrelated jobs on * the same Jenkins slave trying to use the same mock root at the same * time, which will error out. */ - stage('Build RPM (EPEL7)') { - sh """ - mkdir -p mock-result/el7 - flock /etc/mock/epel-7-x86_64.cfg \ - /usr/bin/mock --resultdir=mock-result/el7 -r epel-7-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm - """ - archiveArtifacts artifacts: 'mock-result/el7/**' - } - stage('Build RPM (F25)') { - sh """ - mkdir -p mock-result/f25 - flock /etc/mock/fedora-25-x86_64.cfg \ - /usr/bin/mock --resultdir=mock-result/f25 -r fedora-25-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm - """ - archiveArtifacts artifacts: 'mock-result/f25/**' + stage('Build RPM') { + parallel ( + 'EPEL7': { + sh """ + mkdir -p mock-result/el7 + flock /etc/mock/epel-7-x86_64.cfg \ + /usr/bin/mock --resultdir=mock-result/el7 -r epel-7-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm + """ + archiveArtifacts artifacts: 'mock-result/el7/**' + }, + 'F25': { + sh """ + mkdir -p mock-result/f25 + flock /etc/mock/fedora-25-x86_64.cfg \ + /usr/bin/mock --resultdir=mock-result/f25 -r fedora-25-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm + """ + archiveArtifacts artifacts: 'mock-result/f25/**' + }, + ) } } From 3b11091b4cdb4de83df52bfeef6a94f6f0bd5b6b Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Apr 27 2017 06:09:20 +0000 Subject: [PATCH 2/3] Jenkinsfile: build a Docker container from the built RPM --- diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e4c49ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM centos:7 +RUN yum -y install epel-release && yum -y clean all +# The caller should build a waiverdb RPM package using ./rpmbuild.sh and then pass it in this arg. +ARG waiverdb_rpm +COPY $waiverdb_rpm /tmp +# XXX take out epel-testing eventually +RUN yum -y install --setopt=tsflags=nodocs --enablerepo=epel-testing python-gunicorn /tmp/$(basename $waiverdb_rpm) && yum -y clean all +USER 1001 +EXPOSE 8080 +ENTRYPOINT gunicorn --bind 0.0.0.0:8080 --access-logfile=- waiverdb.wsgi:app diff --git a/Jenkinsfile b/Jenkinsfile index c2ff27b..2062062 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,3 +43,11 @@ node('rcm-tools-jslave-rhel-7') { ) } } +node('rcm-tools-jslave-rhel-7-docker') { + checkout scm + stage('Build Docker container') { + unarchive mapping: ['mock-result/el7/': '.'] + def el7_rpm = findFiles(glob: 'mock-result/el7/**/*.noarch.rpm')[0] + def image = docker.build 'waiverdb', ". --build-arg waiverdb_rpm=$el7_rpm" + } +} From 8b1446c211ce9d822e425bd090ff12b9f884519a Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Apr 27 2017 06:09:23 +0000 Subject: [PATCH 3/3] Jenkinsfile: fix FROM fingerprinting in docker build It was failing like this: java.io.IOException: java.io.FileNotFoundException: /home/jenkins/workspace/waiverdb/waiverdb_rpm=mock-result/el7/waiverdb-0.1-0.git.36.f5bc26b.el7.centos.noarch.rpm/Dockerfile (No such file or directory) because the Docker Pipeline plugin does some dodgy word splitting and parsing of the docker build arguments, and assumes that the source directory is always given last on the command line. --- diff --git a/Jenkinsfile b/Jenkinsfile index 2062062..ff902bb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,6 +48,9 @@ node('rcm-tools-jslave-rhel-7-docker') { stage('Build Docker container') { unarchive mapping: ['mock-result/el7/': '.'] def el7_rpm = findFiles(glob: 'mock-result/el7/**/*.noarch.rpm')[0] - def image = docker.build 'waiverdb', ". --build-arg waiverdb_rpm=$el7_rpm" + /* Note that the docker.build step has some magic to guess the + * Dockerfile used, which will break if the build directory (here ".") + * is not the final argument in the string. */ + def image = docker.build 'waiverdb', "--build-arg waiverdb_rpm=$el7_rpm ." } }