X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fdocker-login.sh;h=d172a3b29f346d68afbdfb01b04ff0df8da2aaf2;hb=a86c6e8d376c95aa00b179fce9d207e61c8f72d0;hp=ca4758f4e167720810f54cfae528a13e344a0455;hpb=dbd05cd4100a27a545cc2c7f0388018449d982c3;p=releng%2Fglobal-jjb.git diff --git a/shell/docker-login.sh b/shell/docker-login.sh index ca4758f4..d172a3b2 100644 --- a/shell/docker-login.sh +++ b/shell/docker-login.sh @@ -8,7 +8,6 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################## -echo "---> docker-login.sh" # Log into a custom hosted docker registry and / or docker.io # $DOCKER_REGISTRY : Optional @@ -43,7 +42,7 @@ echo "---> docker-login.sh" #2) User logging into docker.io with docker version <17.06.0 email optional #3) User logging into docker.io wiht docker version >= 17.06.0 cannot use email flag - +echo "---> docker-login.sh" # Ensure we fail the job if any steps fail set -eu -o pipefail @@ -62,14 +61,12 @@ set_creds() { USER=$(echo "$CREDENTIAL" | cut -f1 -d:) PASS=$(echo "$CREDENTIAL" | cut -f2 -d:) - if [ -z "$USER" ] - then + if [ -z "$USER" ]; then echo "ERROR: No user provided" return 1 fi - if [ -z "$PASS" ] - then + if [ -z "$PASS" ]; then echo "ERROR: No password provided" return 1 fi @@ -93,10 +90,8 @@ do_login() { ### Main ### # Loop through Registry and Ports to concatentate and login to nexus -if [ "${DOCKER_REGISTRY:-none}" != 'none' ] -then - for PORT in $REGISTRY_PORTS - do +if [ "${DOCKER_REGISTRY:-none}" != 'none' ]; then + for PORT in $REGISTRY_PORTS; do REGISTRY="${DOCKER_REGISTRY}:${PORT}" # docker login requests an email address if nothing is passed to it @@ -107,13 +102,13 @@ then fi # Login to docker.io after determining if email is needed. -if [ "${DOCKERHUB_REGISTRY:-none}" != 'none' ] -then +if [ "${DOCKERHUB_REGISTRY:-none}" != 'none' ]; then set_creds "$DOCKERHUB_REGISTRY" - if [ "${DOCKERHUB_EMAIL:-none}" != 'none' ] - then + if [ "${DOCKERHUB_EMAIL:-none}" != 'none' ]; then do_login "$DOCKERHUB_REGISTRY" "$DOCKERHUB_EMAIL" else do_login "$DOCKERHUB_REGISTRY" none fi fi + +echo "---> docker-login.sh ends"