diff --git a/README.md b/README.md index 340b429..9070e17 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ docker run -d -e "CI_SERVER_URL=https://gitlab.com/" \ -e REGISTRATION_TOKEN="$REGISTRATION_TOKEN" \ -e ADMIN_TOKEN="$ADMIN_TOKEN" \ -e PROJECTS_TO_REGISTER="$PROJECTS_TO_REGISTER" \ - -e LOCKED_MODE="false" \ + -e REGISTER_LOCKED="false" \ --name gitlab-runner-testing \ -v /var/run/docker.sock:/var/run/docker.sock \ flakm/gitlab-runner-auto-register:latest @@ -63,17 +63,24 @@ docker exec -i gitlab-runner gitlab-runner register # Environment Variables -| Property | Description | Default value | Required | -| -------------------- | -----------------------------------------------------------------------------------------------------------------------| ------------------------------- | ------------- | -|`CI_SERVER_URL` | url of gitlab instance | | true | -|`REGISTRATION_TOKEN` | /settings/ci_cd tab of your project | | true | -|`PRIVILIGED_MODE` | should you need to run in priviliged mode set to true (otherwise defaults to false) | false | false | -|`LOCKED_MODE` | should this runner be locked to this project or not | true | false | -|`ADMIN_TOKEN` | access token with admin privilages (if specified runner will be registered for projects`PROJECTS_TO_REGISTER`) | | false | -|`PROJECTS_TO_REGISTER` | project ids seperated by `;` | | false | -|`CUSTOM_RUNNER_NAME` | runner's description | `$HOSTNAME` | false | - -For more information about the the environment variables execute `gitlab-runner register --help` inside docker +| Property | Description | Default value | Required | +| -------------------- | -----------------------------------------------------------------------------------------------------------------------------------------| ------------------------------- | ------------- | +|`CI_SERVER_URL` | url of gitlab instance | | true | +|`REGISTRATION_TOKEN` | /settings/ci_cd tab of your project | | true | +|`DOCKER_PRIVILEGED` | should you need to run in priviliged mode set to true (otherwise defaults to false) | false | false | +|`REGISTER_LOCKED` | should this runner be locked to this project or not | true | false | +|`ADMIN_TOKEN` | access token with admin privilages (if specified runner will be registered for projects`PROJECTS_TO_REGISTER`) | | false | +|`PROJECTS_TO_REGISTER` | project ids seperated by `;` | | false | +|`CUSTOM_RUNNER_NAME` | runner's description | `$HOSTNAME` | false | +|`DOCKER_VOLUMES` | volume mounted by this runner | | false | +|`DOCKER_IMAGE` | docker image to use | docker:18.01.0-ce | true | +|`REGISTER_EXTRA_ARGS` | can contain extra arguments for running `gitlab-runner register`.
Can be used for example to specify multiple --docker-volumes args | | false | + +For more information about the the environment variables execute: +``` +docker run --rm --entrypoint "/usr/bin/gitlab-runner" flakm/gitlab-runner-auto-register:latest register --help +``` + # Inspiration diff --git a/entrypoint.sh b/entrypoint.sh index ce3710e..7764937 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,19 +4,15 @@ if [ -z "$CI_SERVER_URL" ]; then CI_SERVER_URL="https://gitlab.com/" fi +if [ -z "$DOCKER_IMAGE" ]; then + export DOCKER_IMAGE=docker:18.01.0-ce +fi + if [ -z "$REGISTRATION_TOKEN" ]; then echo "ERROR: Env REGISTRATION_TOKEN not set!" exit 1 fi -if [ "$PRIVILIGED_MODE" != "true" ]; then - PRIVILIGED_MODE="false" -fi - -if [ "$LOCKED_MODE" != "true" ]; then - LOCKED_MODE="true" -fi - if [ "$ADMIN_TOKEN" != "" ]; then REGISTER_OTHER_PROJECTS="true" PROJECTS_STRING="$PROJECTS_TO_REGISTER" @@ -55,7 +51,7 @@ trap "gitlab-runner stop" SIGTERM echo "===> Running gitlab-runner register..." export REGISTER_NON_INTERACTIVE=true -gitlab-runner register --executor=docker --locked=$LOCKED_MODE --docker-image=docker:latest --docker-privileged=$PRIVILIGED_MODE --docker-volumes=/var/run/docker.sock:/var/run/docker.sock +gitlab-runner register --executor=docker $REGISTER_EXTRA_ARGS if [ $? -gt 0 ]; then echo "===> ERROR: Registration failed!" exit 1