[SDFAB-244] Fix docker-login when checking if variables exist
Change-Id: I43de5d71a4b35af89bfb18ff964fb3729a2a69e9
diff --git a/jjb/shell/docker-login.sh b/jjb/shell/docker-login.sh
index 444bf61..689cfc0 100644
--- a/jjb/shell/docker-login.sh
+++ b/jjb/shell/docker-login.sh
@@ -19,19 +19,28 @@
# exit on errors
set -eu -o pipefail
-if [ -n "${DOCKERHUB_USERNAME}" ]
+DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME:-}
+DOCKERHUB_PASSWORD=${DOCKERHUB_PASSWORD:-}
+
+if [[ -n "$DOCKERHUB_USERNAME" && -n "$DOCKERHUB_PASSWORD" ]]
then
echo "Docker login: docker.io"
docker login --username "${DOCKERHUB_USERNAME}" --password "${DOCKERHUB_PASSWORD}"
fi
-if [ -n "${AETHER_REGISTRY_USERNAME}" ]
+AETHER_REGISTRY_USERNAME=${AETHER_REGISTRY_USERNAME:-}
+AETHER_REGISTRY_PASSWORD=${AETHER_REGISTRY_PASSWORD:-}
+
+if [[ -n "$AETHER_REGISTRY_USERNAME" && -n "$AETHER_REGISTRY_PASSWORD" ]]
then
echo "Docker login: registry.aetherproject.org"
docker login registry.aetherproject.org --username "${AETHER_REGISTRY_USERNAME}" --password "${AETHER_REGISTRY_PASSWORD}"
fi
-if [ -n "${ONF_REGISTRY_USERNAME}" ]
+ONF_REGISTRY_USERNAME=${ONF_REGISTRY_USERNAME:-}
+ONF_REGISTRY_PASSWORD=${ONF_REGISTRY_PASSWORD:-}
+
+if [[ -n "$ONF_REGISTRY_USERNAME" && -n "$ONF_REGISTRY_PASSWORD" ]]
then
echo "Docker login: registry.opennetworking.org"
docker login registry.opennetworking.org --username "${ONF_REGISTRY_USERNAME}" --password "${ONF_REGISTRY_PASSWORD}"