From 87aaf01e1ce3ade5f5638a6c365bb264ea99102a Mon Sep 17 00:00:00 2001 From: "hv11277@jarvis" Date: Mon, 8 Jan 2018 09:26:27 +0100 Subject: [PATCH] - Update prepareScript and - --docker-extra-hosts for gitlab-runner enables checkout via hostname --- gitlabrunner/entrypointAutoregister | 10 +++++----- prepareCompose.sh | 12 +++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gitlabrunner/entrypointAutoregister b/gitlabrunner/entrypointAutoregister index 00d061f..553b0c5 100644 --- a/gitlabrunner/entrypointAutoregister +++ b/gitlabrunner/entrypointAutoregister @@ -32,17 +32,17 @@ fi TRYS=$REGISTER_TRYS REGISTERED=1 -if test $REGISTER_MODE = "FRESH" -o $RUNNER_IS_PRESENT -ne 0 ; then +if test $REGISTER_MODE = "FRESH" -o $RUNNER_IS_PRESENT -ne 0 ; then while test $TRYS -gt 0 -a $REGISTERED -gt 0 ; do TRYS=$(expr $TRYS - 1) gitlab-runner register -n --url=${GITLAB_URL} --registration-token=${REGISTER_TOKEN} \ --executor=docker --name=docker-multi-runner \ --run-untagged=true --locked=false --docker-image=docker:latest \ --docker-privileged \ - --docker-extra-hosts="jarvis:192.168.34.98" + --docker-extra-hosts="HOSTNAME:HOSTIP" REGISTERED=$? if [ $REGISTERED -ne 0 ] ; then - echo "${GITLAB_URL} not ready $TRYS trys left, next try in 10 second for ${GITLAB_URL}" + echo "${GITLAB_URL} not ready $TRYS trys left, next try in 10 second for ${GITLAB_URL}" sleep 10 else # Gitlab is ready, so remove ALL runner and re-registrer only one runner @@ -56,9 +56,9 @@ if test $REGISTER_MODE = "FRESH" -o $RUNNER_IS_PRESENT -ne 0 ; then --executor=docker --name=docker-multi-runner \ --run-untagged=true --locked=false --docker-image=docker:latest \ --docker-privileged \ - --docker-extra-hosts="jarvis:192.168.34.98" + --docker-extra-hosts="HOSTNAME:HOSTIP" fi - done + done fi # launch gitlab-ci-multi-runner passing all arguments diff --git a/prepareCompose.sh b/prepareCompose.sh index ac838ee..c3ad34f 100755 --- a/prepareCompose.sh +++ b/prepareCompose.sh @@ -25,11 +25,12 @@ echo "Setting HOSTNAME to $GIVEN_HOSTNAME" HOSTNAME=$GIVEN_HOSTNAME echo "Type your hostIP, I guess it is one of $(hostname -I) " -echo "Remember, 127.0.0.1 is NOT the correct IP and the docker-Network starts with 172.x.y.z" - +echo "Remember, 127.0.0.1 is NOT the correct IP and the docker-Network starts with 172.x.y.z and is also not correct" + read -e -p "Your hostIP : " -i $HOSTIP GIVEN_HOSTIP HOSTIP=$GIVEN_HOSTIP - +echo "Setting HOSTIP to $GIVEN_HOSTIP" +echo " " type openssl 2>/dev/null if [ $? -eq 0 ] ; then echo "openssl installed :-)" @@ -95,6 +96,11 @@ cp -r preconfig/jenkins/* $USER_DATA_DIR/jenkins/ sed s#BASE_DATA_DIR#${USER_DATA_DIR}#g docker-compose.yml.template > docker-compose.yml sed -i s#HOSTIP#${HOSTIP}#g docker-compose.yml sed -i s#HOSTNAME#${HOSTNAME}#g docker-compose.yml + +# Gitlabrunner needs extra_hosts to clone stuff via hostname +sed -i s#HOSTNAME#${HOSTNAME}#g gitlabrunner/entrypointAutoregister +sed -i s#HOSTIP#${HOSTIP}#g gitlabrunner/entrypointAutoregister + chmod a+rw docker-compose.yml echo "-------------------------------------------------------------------------------------------" echo "-------------------------------------------------------------------------------------------"