Skip to content

Commit

Permalink
- Update prepareScript and
Browse files Browse the repository at this point in the history
- --docker-extra-hosts for gitlab-runner enables checkout via hostname
  • Loading branch information
hv11277@jarvis committed Jan 8, 2018
1 parent ee63ff5 commit 87aaf01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 5 additions & 5 deletions gitlabrunner/entrypointAutoregister
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions prepareCompose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 :-)"
Expand Down Expand Up @@ -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 "-------------------------------------------------------------------------------------------"
Expand Down

0 comments on commit 87aaf01

Please sign in to comment.