summaryrefslogtreecommitdiffstats
path: root/hack/push-release.sh
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2016-12-08 11:52:30 -0500
committerBrenton Leanhardt <bleanhar@redhat.com>2017-03-07 15:51:15 -0500
commit77441837777312dbed93fe98f0058501bd6aefbd (patch)
treeb69a802d392f05897114b276b769f18aed9db66f /hack/push-release.sh
parented103af9a9fb6f99f4c2f4d040649698d67eb6b0 (diff)
downloadopenshift-77441837777312dbed93fe98f0058501bd6aefbd.tar.gz
openshift-77441837777312dbed93fe98f0058501bd6aefbd.tar.bz2
openshift-77441837777312dbed93fe98f0058501bd6aefbd.tar.xz
openshift-77441837777312dbed93fe98f0058501bd6aefbd.zip
Adding scripts for building and pushing images
These scripts follow the same pattern as the origin and origin-metrics repo. From there the Jenkins job will be very simple.
Diffstat (limited to 'hack/push-release.sh')
-rwxr-xr-xhack/push-release.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/hack/push-release.sh b/hack/push-release.sh
new file mode 100755
index 000000000..8639143af
--- /dev/null
+++ b/hack/push-release.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# This script pushes all of the built images to a registry.
+#
+# Set OS_PUSH_BASE_REGISTRY to prefix the destination images
+#
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+STARTTIME=$(date +%s)
+OS_ROOT=$(dirname "${BASH_SOURCE}")/..
+
+PREFIX="${PREFIX:-openshift/openshift-ansible}"
+
+# Go to the top of the tree.
+cd "${OS_ROOT}"
+
+# Allow a release to be repushed with a tag
+tag="${OS_PUSH_TAG:-}"
+if [[ -n "${tag}" ]]; then
+ tag=":${tag}"
+else
+ tag=":latest"
+fi
+
+# Source tag
+source_tag="${OS_TAG:-}"
+if [[ -z "${source_tag}" ]]; then
+ source_tag="latest"
+fi
+
+images=(
+ ${PREFIX}
+)
+
+PUSH_OPTS=""
+if docker push --help | grep -q force; then
+ PUSH_OPTS="--force"
+fi
+
+if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" || "${tag}" != "" ]]; then
+ set -e
+ for image in "${images[@]}"; do
+ docker tag "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
+ done
+ set +e
+fi
+
+for image in "${images[@]}"; do
+ docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}"
+done
+
+ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"