Skip to content

Commit

Permalink
added RUNNER_AUTOUNREGISTER variable to unregister the runner on stop
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalLumberjack committed Feb 5, 2017
1 parent e3a7ab6 commit 71fbf3d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ENV RUNNER_DOCKER_PRIVATE_REGISTRY_URL=''
ENV RUNNER_DOCKER_PRIVATE_REGISTRY_TOKEN=''
ENV RUNNER_DOCKER_ADDITIONAL_VOLUME=''
ENV RUNNER_OUTPUT_LIMIT='4096'
ENV RUNNER_AUTOUNREGISTER='false'

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E1DD270288B4E6030699E45FA1715D88E1DF1F24 \
&& echo "deb http://ppa.launchpad.net/git-core/ppa/ubuntu trusty main" >> /etc/apt/sources.list \
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ docker run --name gitlab-ci-multi-runner -d --restart=always \

Update the values of `CI_SERVER_URL`, `RUNNER_TOKEN` and `RUNNER_DESCRIPTION` in the above command. If these enviroment variables are not specified, you will be prompted to enter these details interactively on first run.

## Available variables

You can customise the runner with the following env variables:
- CA_CERTIFICATES_PATH: the path to your certificate
- RUNNER_CONCURRENT: the number of concurrent job the runner can start
- CI_SERVER_URL: your server URL (suffixed by /ci)
- RUNNER_TOKEN: the runner token corresponding to your project
- RUNNER_EXECUTOR: the executor to start
- RUNNER_DESCRIPTION: the description of the runner, displayed in gitlab ui
- RUNNER_DOCKER_IMAGE: the default image to run when starting a build
- RUNNER_DOCKER_MODE: the docker mode to use, socket or dind
- RUNNER_DOCKER_PRIVATE_REGISTRY_URL: url of private registry the runner should access
- RUNNER_DOCKER_PRIVATE_REGISTRY_TOKEN: token of private registry the runner should access
- RUNNER_DOCKER_ADDITIONAL_VOLUME: additionals volumes to share between host and jobs
- RUNNER_OUTPUT_LIMIT: output limit in KB that a build can produce
- RUNNER_AUTOUNREGISTER: auto unregister the runner when the container stops

## Using docker executor

You can use the docker executor by using `RUNNER_EXECUTOR=docker`. You must provide a docker image to use in `RUNNER_DOCKER_IMAGE` (e.g. docker:latest)
Expand Down
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ if [[ -z ${1} ]]; then
--exec $(which gitlab-ci-multi-runner) -- run \
--working-directory ${GITLAB_CI_MULTI_RUNNER_DATA_DIR} \
--config ${GITLAB_CI_MULTI_RUNNER_DATA_DIR}/config.toml ${EXTRA_ARGS}
echo "Stopping runner"
if [[ "${RUNNER_AUTOUNREGISTER}" == "true" ]];then
echo "Unregistering runner from ${CI_SERVER_URL}"
sudo -HEu ${GITLAB_CI_MULTI_RUNNER_USER} \
gitlab-ci-multi-runner unregister --url ${CI_SERVER_URL} --token $(grep token ${GITLAB_CI_MULTI_RUNNER_DATA_DIR}/config.toml | awk '{print $3}' | tr -d '"')
fi
else
exec "$@"
fi

0 comments on commit 71fbf3d

Please sign in to comment.