X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fdocker-login.sh;h=73d0603c75bdd5c12c0df3a15f2337ac12e86da6;hb=refs%2Fchanges%2F59%2F72659%2F3;hp=751ac20be3981479df9a19a32be8a501123e65b5;hpb=40d61a6fd4fdc64240fc298e039d9f88215e5e40;p=releng%2Fglobal-jjb.git diff --git a/shell/docker-login.sh b/shell/docker-login.sh index 751ac20b..73d0603c 100644 --- a/shell/docker-login.sh +++ b/shell/docker-login.sh @@ -46,8 +46,10 @@ echo "---> docker-login.sh" # Ensure we fail the job if any steps fail set -eu -o pipefail -#Check if current version less than desired version -version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +# Check if current version less than desired version +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; +} # Execute the credential lookup and set set_creds() { @@ -61,14 +63,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 @@ -79,7 +79,7 @@ set_creds() { do_login() { docker_version=$( docker -v | awk '{print $3}') if version_lt "$docker_version" "17.06.0" && \ - "$DOCKERHUB_REGISTRY" == "docker.io" && \ + [ "$DOCKERHUB_REGISTRY" == "docker.io" ] && \ "$DOCKERHUB_EMAIL:-none" != 'none' then docker login -u "$USER" -p "$PASS" -e "$2" "$1" @@ -92,8 +92,7 @@ do_login() { ### Main ### # Loop through Registry and Ports to concatentate and login to nexus -if [ "${DOCKER_REGISTRY:-none}" != 'none' ] -then +if [ "${DOCKER_REGISTRY:-none}" != 'none' ]; then for PORT in $REGISTRY_PORTS; do REGISTRY="${DOCKER_REGISTRY}:${PORT}" @@ -105,11 +104,9 @@ 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