Skip to content

Instantly share code, notes, and snippets.

@T4cC0re
Created October 28, 2016 20:17
Show Gist options
  • Save T4cC0re/1ea4c0e2a870e0ea50c348acf666281a to your computer and use it in GitHub Desktop.
Save T4cC0re/1ea4c0e2a870e0ea50c348acf666281a to your computer and use it in GitHub Desktop.
install gitlab-ci-multi-runner in docker mode on ubuntu based machines. Docker needs to be installed beforehand
#!/usr/bin/env bash
echo "check if gitlab-ci-multi-runner is installed..."
gitlab-ci-multi-runner &> /dev/null
if [ $? != 0 ]; then
echo "NOT installed. Installing..."
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash
apt-get install gitlab-ci-multi-runner
else
echo "IS installed. OK"
fi
echo "Removing broken runners if existent..."
gitlab-ci-multi-runner verify --delete
echo "OK"
echo "check if docker is running..."
docker info &> /dev/null
if [ $? != 0 ]; then
echo "ERROR: docker info failed. Exitting"
exit 1
else
echo "OK"
fi
DETECTED_RUNNERS="$(expr $(gitlab-ci-multi-runner list 2>&1 | wc -l) - 1)"
echo "detected ${DETECTED_RUNNERS} runners..."
if [ $DETECTED_RUNNERS -lt 1 ]; then
# exits with 1 if no runner is registered
echo "No runner registered... Registering..."
export REGISTRATION_TOKEN="PUT TOKEN HERE"
export RUNNER_TAG_LIST="$(hostname -f),$(uname -m),$(arch),docker"
export CI_SERVER_URL="https://my.git.lab/ci"
export RUNNER_EXECUTOR="docker"
export RUNNER_NAME="$(hostname -f)"
if [ "$(arch)" = "armv7l" ]; then
export DOCKER_IMAGE=""
elif [ "$(arch)" = "x86_64" ]; then
export DOCKER_IMAGE="ubuntu"
else
echo "arch not supported"
exit 1
fi
gitlab-ci-multi-runner register -n
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment