Commit 724f3dbb authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Mejora salida de texto del proceso

parent 3d21cd1f
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -2,8 +2,14 @@

SERVICES_TO_CHECK="${SERVICES_TO_CHECK:-${STACK:-${SERVICE}}}"

echo -e "\n${INFO_COLOR}Checking deployment of services [ ${SERVICES_TO_CHECK} ]..${NULL_COLOR}\n"

for serviceToCheck in ${SERVICES_TO_CHECK}
do
	echo -e "\n${INFO_COLOR}Checking deployment of service ${serviceToCheck}..${NULL_COLOR}"
	echo -e "  ${INFO_COLOR}retries ${STATUS_CHECK_RETRIES}, interval ${STATUS_CHECK_INTERVAL}, min. hits \
		${STATUS_CHECK_MIN_HITS}${NULL_COLOR}\n"

	checkDeployCmd="\
		docker stack ls > /dev/null 2> /dev/null ; \
		if [ \"\${?}\" -eq \"0\" ] ; \
@@ -13,7 +19,7 @@ do
		hits=0 && \
		for i in \$(seq 1 ${STATUS_CHECK_RETRIES}) ; \
		do \
			echo \"Checking service ${serviceToCheck} status, try \${i}/${STATUS_CHECK_RETRIES} ...\" && \
			echo -e \"  try \${i}/${STATUS_CHECK_RETRIES} .. \\c\" && \
			if [ \"\${SWARM_MODE}\" = true ] ; \
			then \
				stackServices=\$(docker service ls -f name=${serviceToCheck} --format '{{.Replicas}}') ; \
@@ -38,7 +44,7 @@ do
				hits=\$((\${hits} + 1)) && \
				if [ \"\${hits}\" -eq \"${STATUS_CHECK_MIN_HITS}\" ] ; \
				then \
					echo -e \"${PASS_COLOR}Service ${serviceToCheck} is running!${NULL_COLOR}\" && \
					echo -e \"\\n${PASS_COLOR}Service ${serviceToCheck} is running!${NULL_COLOR}\" && \
					echo -e \"  got ${PASS_COLOR}\${hits}/${STATUS_CHECK_MIN_HITS}${NULL_COLOR} status hits\" && \
					exit 0 ; \
				fi ; \
@@ -47,9 +53,10 @@ do
			fi ; \
			sleep ${STATUS_CHECK_INTERVAL} ; \
		done ; \
		echo -e \"${FAIL_COLOR}Service ${serviceToCheck} is not running!${NULL_COLOR}\" && \
		echo -e \"\\n${FAIL_COLOR}Service ${serviceToCheck} is not running!${NULL_COLOR}\" && \
		echo -e \"  got ${FAIL_COLOR}\${hits}/${STATUS_CHECK_MIN_HITS}${NULL_COLOR} status hits\" && \
		exit 1 \
	"

	ssh ${SSH_PARAMS} "${SSH_REMOTE}" "${checkDeployCmd}"
done
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ STATUS_CHECK_INTERVAL="${STATUS_CHECK_INTERVAL:-5}"
STATUS_CHECK_DELAY="${STATUS_CHECK_DELAY:-20}"
STATUS_CHECK_MIN_HITS="${STATUS_CHECK_MIN_HITS:-3}"

INFO_COLOR='\033[0;36m'
FAIL_COLOR='\033[0;31m'
PASS_COLOR='\033[0;32m'
NULL_COLOR='\033[0m'
+3 −1
Original line number Diff line number Diff line
#!/bin/sh

echo -e "\n${INFO_COLOR}Deploying at remote target..${NULL_COLOR}\n"

deployCmd="\
	cd ${DEPLOY_HOME} && \
	docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} && \
@@ -18,5 +20,5 @@ deployCmd="\
		rm ${DEFAULT_DEPLOY_FILES} ; \
	fi\
"
ssh ${SSH_PARAMS} "${SSH_REMOTE}" "${deployCmd}"

ssh ${SSH_PARAMS} "${SSH_REMOTE}" "${deployCmd}"
+2 −0
Original line number Diff line number Diff line
#!/bin/sh

echo -e "\n${INFO_COLOR}Preparing deploy configuration and resources..${NULL_COLOR}\n"

# Se comprueba si se despliega desde dentro de 'deploy' o desde la raíz del proyecto.
if [ -d "${DEPLOY_DIR_NAME}" ]
then
+8 −2
Original line number Diff line number Diff line
@@ -2,15 +2,21 @@

. _definitions.sh

echo -e "\n${INFO_COLOR}Preparing connection to remote target..${NULL_COLOR}\n"

if [ -z "${SSH_REMOTE}" ]
then
	echo -e "${FAIL_COLOR}You must define 'SSH_REMOTE' in environment, with remote user and hostname (like 'ssh-user@ssh-remote')${NULL_COLOR}"
	echo -e "${FAIL_COLOR}You must define 'SSH_REMOTE' in environment, with remote user and hostname (like \
		'ssh-user@ssh-remote')${NULL_COLOR}"

	exit 1
fi

if [ -z "${GITLAB_DEPLOY_KEY}" ]
then
	echo -e "${FAIL_COLOR}You must define 'GITLAB_DEPLOY_KEY' in environment, with a SSH private key accepted by remote server${NULL_COLOR}"
	echo -e "${FAIL_COLOR}You must define 'GITLAB_DEPLOY_KEY' in environment, with a SSH private key accepted by \
		remote server${NULL_COLOR}"

	exit 1
fi

Loading