From 92fcd3300638300580ee90c22307fbb07c618974 Mon Sep 17 00:00:00 2001 From: Brian Lin Date: Mon, 16 Dec 2019 13:43:09 -0600 Subject: [PATCH 1/4] Move DockerHub org and repo values to the Travis CI environment --- .travis.yml | 3 +++ travis/build_docker.sh | 8 +++----- travis/push_docker.sh | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddd83ef7..d5bcb4e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ services: - docker +env: + - DOCKER_ORG='opensciencegrid' DOCKER_REPOS='xcache stash-cache stash-origin atlas-xcache cms-xcache' + script: - ./travis/build_docker.sh - ./travis/test_stashcache_origin.sh diff --git a/travis/build_docker.sh b/travis/build_docker.sh index 5eba6af2..7984c844 100755 --- a/travis/build_docker.sh +++ b/travis/build_docker.sh @@ -1,14 +1,12 @@ #!/bin/bash -xe # Script for building and pushing XCache docker images -org='opensciencegrid' timestamp=`date +%Y%m%d-%H%M` -docker_repos='xcache stash-cache stash-origin atlas-xcache cms-xcache' -for repo in $docker_repos; do +for repo in $DOCKER_REPOS; do docker build \ - -t $org/$repo:fresh \ - -t $org/$repo:$timestamp \ + -t $DOCKER_ORG/$repo:fresh \ + -t $DOCKER_ORG/$repo:$timestamp \ $repo done diff --git a/travis/push_docker.sh b/travis/push_docker.sh index d5923ca2..24d6c01b 100755 --- a/travis/push_docker.sh +++ b/travis/push_docker.sh @@ -9,8 +9,8 @@ fi # Credentials for docker push echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin -for repo in $docker_repos; do +for repo in $DOCKER_REPOS; do for tag in $timestamp fresh; do - docker push $org/$repo:$tag + docker push $DOCKER_ORG/$repo:$tag done done From cce1382ebab743c0645cf1669f2b9cda1926f642 Mon Sep 17 00:00:00 2001 From: Brian Lin Date: Mon, 16 Dec 2019 13:49:16 -0600 Subject: [PATCH 2/4] Add Travis wrapper script Since both build and push scripts need the same timestamp --- .travis.yml | 5 +---- travis/build_docker.sh | 2 +- travis/push_docker.sh | 2 ++ travis/travis-wrapper.sh | 9 +++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100755 travis/travis-wrapper.sh diff --git a/.travis.yml b/.travis.yml index d5bcb4e8..518c1c53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,7 @@ env: - DOCKER_ORG='opensciencegrid' DOCKER_REPOS='xcache stash-cache stash-origin atlas-xcache cms-xcache' script: - - ./travis/build_docker.sh - - ./travis/test_stashcache_origin.sh - - ./travis/test_stashcache.sh - - ./travis/push_docker.sh + - ./travis/travis-wrapper.sh branches: only: diff --git a/travis/build_docker.sh b/travis/build_docker.sh index 7984c844..2146a79f 100755 --- a/travis/build_docker.sh +++ b/travis/build_docker.sh @@ -1,7 +1,7 @@ #!/bin/bash -xe # Script for building and pushing XCache docker images -timestamp=`date +%Y%m%d-%H%M` +timestamp="$1" for repo in $DOCKER_REPOS; do docker build \ diff --git a/travis/push_docker.sh b/travis/push_docker.sh index 24d6c01b..aeae5cdb 100755 --- a/travis/push_docker.sh +++ b/travis/push_docker.sh @@ -6,6 +6,8 @@ if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then exit 0 fi +timestamp="$1" + # Credentials for docker push echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin diff --git a/travis/travis-wrapper.sh b/travis/travis-wrapper.sh new file mode 100755 index 00000000..b11810a7 --- /dev/null +++ b/travis/travis-wrapper.sh @@ -0,0 +1,9 @@ +#!/bin/bash -xe +# Wrapper script for building and testing XCache container images + +timestamp=`date +%Y%m%d-%H%M` + +./build_docker.sh $timestamp +./test_stashcache_origin.sh +./test_stashcache.sh +./push_docker.sh $timestamp From 618df627ecd1f33ff3df2754ed62448dca56d357 Mon Sep 17 00:00:00 2001 From: Brian Lin Date: Mon, 16 Dec 2019 13:53:26 -0600 Subject: [PATCH 3/4] Run other scripts from the travis/ dir --- travis/travis-wrapper.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/travis/travis-wrapper.sh b/travis/travis-wrapper.sh index b11810a7..b3d91a93 100755 --- a/travis/travis-wrapper.sh +++ b/travis/travis-wrapper.sh @@ -3,6 +3,8 @@ timestamp=`date +%Y%m%d-%H%M` +cd travis + ./build_docker.sh $timestamp ./test_stashcache_origin.sh ./test_stashcache.sh From dac9b96f5a9d4f0a087f20ef3be90f3fa761173f Mon Sep 17 00:00:00 2001 From: Brian Lin Date: Mon, 16 Dec 2019 14:02:13 -0600 Subject: [PATCH 4/4] Scripts expect to be run from the repo root dir --- travis/travis-wrapper.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/travis/travis-wrapper.sh b/travis/travis-wrapper.sh index b3d91a93..9918af83 100755 --- a/travis/travis-wrapper.sh +++ b/travis/travis-wrapper.sh @@ -3,9 +3,7 @@ timestamp=`date +%Y%m%d-%H%M` -cd travis - -./build_docker.sh $timestamp -./test_stashcache_origin.sh -./test_stashcache.sh -./push_docker.sh $timestamp +./travis/build_docker.sh $timestamp +./travis/test_stashcache_origin.sh +./travis/test_stashcache.sh +./travis/push_docker.sh $timestamp