From 363e0f64d3f76fee9fd35a4cddd90982d285383b Mon Sep 17 00:00:00 2001 From: jmoore Date: Tue, 10 Nov 2015 09:24:44 +0100 Subject: [PATCH 1/5] Add SPACEUSER --- jenkins/Dockerfile | 2 +- rename.py | 11 +++++++++-- slave/Dockerfile | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/jenkins/Dockerfile b/jenkins/Dockerfile index 1022e72b..afee3a75 100644 --- a/jenkins/Dockerfile +++ b/jenkins/Dockerfile @@ -2,7 +2,7 @@ FROM jenkins MAINTAINER OME USER root -RUN usermod -u 11521 jenkins +RUN usermod -u SPACEUSER jenkins RUN chown -R jenkins /usr/share/jenkins/ RUN chown -R jenkins /var/log/copy_reference_file.log USER jenkins diff --git a/rename.py b/rename.py index da8b6fd0..6e5f6b31 100755 --- a/rename.py +++ b/rename.py @@ -5,10 +5,11 @@ import fnmatch import os -def replace(name, branch): +def replace(name, branch, uid): for root, dir, files in os.walk("."): yml = list(fnmatch.filter(files, "*.yml")) xml = list(fnmatch.filter(files, "*.xml")) + dkr = list(fnmatch.filter(files, "Dockerfile")) for f in yml + xml: fname = os.path.join(root, f) print "Setting space to '%s' in %s" % (name, fname) @@ -16,9 +17,15 @@ def replace(name, branch): line = line.replace("SPACENAME", name) line = line.replace("SPACEBRANCH", name) print line, + for f in dkr: + fname = os.path.join(root, f) + for line in fileinput.input([fname], inplace=True): + line = line.replace("SPACEUSER", str(uid)) + print line, if __name__ == "__main__": parser = argparse.ArgumentParser() + parser.add_argument("--uid", type=int, default=os.getuid()) parser.add_argument("name") parser.add_argument("branch", nargs="?") ns = parser.parse_args() @@ -27,5 +34,5 @@ def replace(name, branch): if not branch: branch = name - replace(name, branch) + replace(name, branch, ns.uid) print "Done. You may want to review and commit your changes now" diff --git a/slave/Dockerfile b/slave/Dockerfile index 3e22643d..9c001154 100644 --- a/slave/Dockerfile +++ b/slave/Dockerfile @@ -6,7 +6,7 @@ ENV JENKINS_SWARM_VERSION 1.24 ENV HOME /home/jenkins-slave RUN useradd -c "Jenkins Slave user" -d $HOME -m jenkins-slave -RUN usermod -u 11521 jenkins-slave +RUN usermod -u SPACEUSER jenkins-slave RUN curl --create-dirs -sSLo /usr/share/jenkins/swarm-client-$JENKINS_SWARM_VERSION-jar-with-dependencies.jar http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/$JENKINS_SWARM_VERSION/swarm-client-$JENKINS_SWARM_VERSION-jar-with-dependencies.jar \ && chmod 755 /usr/share/jenkins From acac331fb04f5379b2893f5aa3c2a9be71c2dfe6 Mon Sep 17 00:00:00 2001 From: jmoore Date: Tue, 10 Nov 2015 09:32:18 +0100 Subject: [PATCH 2/5] Remove unneeded chown --- jenkins/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/jenkins/Dockerfile b/jenkins/Dockerfile index afee3a75..86796778 100644 --- a/jenkins/Dockerfile +++ b/jenkins/Dockerfile @@ -4,7 +4,6 @@ MAINTAINER OME USER root RUN usermod -u SPACEUSER jenkins RUN chown -R jenkins /usr/share/jenkins/ -RUN chown -R jenkins /var/log/copy_reference_file.log USER jenkins COPY plugins.txt /usr/share/jenkins/plugins.txt From 35543041adb0c10b0a7484b11a15bfff5dcd3a77 Mon Sep 17 00:00:00 2001 From: jmoore Date: Wed, 11 Nov 2015 17:51:51 +0100 Subject: [PATCH 3/5] Replace tags image with a locally built version --- docker-compose.yml | 2 +- git/Dockerfile | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 git/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 041066ca..ef8a72fe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ jenkins: - SERVICE_NAME=SPACENAME-ci git: - image: openmicroscopy/tags:5.1.1 + build: git volumes: - /src command: 'true' diff --git a/git/Dockerfile b/git/Dockerfile new file mode 100644 index 00000000..97f04b1e --- /dev/null +++ b/git/Dockerfile @@ -0,0 +1,13 @@ +FROM mini/base +MAINTAINER ome-devel@lists.openmicroscopy.org.uk + +ENV TAG 5.1.4 + +RUN apk-install git && \ + mkdir /src + +RUN time git clone --bare --depth=1 -b v$TAG git://github.com/ome/scripts/ /src/scripts.git +RUN time git clone --bare --depth=1 -b v$TAG git://github.com/openmicroscopy/openmicroscopy /src/omero.git +RUN time git clone --bare --depth=1 -b v$TAG git://github.com/openmicroscopy/bioformats /src/bio-formats.git + +WORKDIR /src From 9a6e308fd72b5e152e8ea5596663c60387ece766 Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 12 Nov 2015 08:49:09 +0100 Subject: [PATCH 4/5] travis: improve called steps --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7d4f3e1b..2dffb1cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,11 @@ services: - docker before_install: -- docker-compose build +- ./rename.py travis install: +- docker-compose build + +script: - docker-compose up -d slave - docker-compose stop From d142b4719bbd599079e66bcd8876f45a90bb4f4e Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 12 Nov 2015 08:52:53 +0100 Subject: [PATCH 5/5] rename.py: assert the number of changes made --- rename.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rename.py b/rename.py index 6e5f6b31..d907678d 100755 --- a/rename.py +++ b/rename.py @@ -6,6 +6,7 @@ import os def replace(name, branch, uid): + cnt = 0 for root, dir, files in os.walk("."): yml = list(fnmatch.filter(files, "*.yml")) xml = list(fnmatch.filter(files, "*.xml")) @@ -14,14 +15,19 @@ def replace(name, branch, uid): fname = os.path.join(root, f) print "Setting space to '%s' in %s" % (name, fname) for line in fileinput.input([fname], inplace=True): - line = line.replace("SPACENAME", name) - line = line.replace("SPACEBRANCH", name) + if "SPACE" in line: + cnt += 1 + line = line.replace("SPACENAME", name) + line = line.replace("SPACEBRANCH", name) print line, for f in dkr: fname = os.path.join(root, f) for line in fileinput.input([fname], inplace=True): - line = line.replace("SPACEUSER", str(uid)) + if "SPACE" in line: + cnt += 1 + line = line.replace("SPACEUSER", str(uid)) print line, + return cnt if __name__ == "__main__": parser = argparse.ArgumentParser() @@ -34,5 +40,6 @@ def replace(name, branch, uid): if not branch: branch = name - replace(name, branch, ns.uid) + # This number will need to be updated when new changes are commited. + assert 19 == replace(name, branch, ns.uid) print "Done. You may want to review and commit your changes now"