diff --git a/images/oc-build-deploy-dind/build-deploy-docker-compose.sh b/images/oc-build-deploy-dind/build-deploy-docker-compose.sh index fa9982ba9e..3f9d3141eb 100755 --- a/images/oc-build-deploy-dind/build-deploy-docker-compose.sh +++ b/images/oc-build-deploy-dind/build-deploy-docker-compose.sh @@ -37,12 +37,35 @@ function cronScheduleMoreOftenThanXMinutes() { ### PREPARATION ############################################## +DEPLOY_TYPE=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.deploy-type default) + +### Compatibility for new Lagoon 2.0 variables + +# Only if TYPE is not set and BUILD_TYPE is set +if [[ -z ${TYPE+x} && ! -z ${BUILD_TYPE+x} ]]; then + TYPE=${BUILD_TYPE} +fi + +# Only if SAFE_BRANCH is not set and BRANCH is set +if [[ -z ${SAFE_BRANCH+x} && ! -z ${BRANCH+x} ]]; then + SAFE_BRANCH=${BRANCH} +fi + +# Only if SAFE_PROJECT is not set and PROJECT is set +if [[ -z ${SAFE_PROJECT+x} && ! -z ${PROJECT+x} ]]; then + SAFE_PROJECT=${PROJECT} +fi + + +# Only if OPENSHIFT_NAME is not set and KUBERNETES is set +if [[ -z ${OPENSHIFT_NAME+x} && ! -z ${KUBERNETES+x} ]]; then + OPENSHIFT_NAME=${KUBERNETES} +fi + # Load path of docker-compose that should be used set +x # reduce noise in build logs DOCKER_COMPOSE_YAML=($(cat .lagoon.yml | shyaml get-value docker-compose-yaml)) -DEPLOY_TYPE=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.deploy-type default) - # Load all Services that are defined COMPOSE_SERVICES=($(cat $DOCKER_COMPOSE_YAML | shyaml keys services)) diff --git a/images/oc-build-deploy-dind/build-deploy.sh b/images/oc-build-deploy-dind/build-deploy.sh index 69546b94ad..2327552779 100755 --- a/images/oc-build-deploy-dind/build-deploy.sh +++ b/images/oc-build-deploy-dind/build-deploy.sh @@ -44,7 +44,12 @@ fi set +x DOCKER_REGISTRY_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) -docker login -u=jenkins -p="${DOCKER_REGISTRY_TOKEN}" ${OPENSHIFT_REGISTRY} +DEPLOY_TYPE=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.deploy-type default) + +# Do not run if this a DEPLOY_TYPE=tug which means we just push images to an external registry, we don't need to be logged into the OpenShift Registry +if [[ ! $DEPLOY_TYPE == "tug" ]]; then + docker login -u=jenkins -p="${DOCKER_REGISTRY_TOKEN}" ${OPENSHIFT_REGISTRY} +fi INTERNAL_REGISTRY_LOGGED_IN="false" if [ ! -z ${INTERNAL_REGISTRY_URL} ] && [ ! -z ${INTERNAL_REGISTRY_USERNAME} ] && [ ! -z ${INTERNAL_REGISTRY_PASSWORD} ] ; then