From 72a5ae8a09f43b8de1739965a1f5f002e3f78860 Mon Sep 17 00:00:00 2001 From: DEvil0000 Date: Fri, 21 Jan 2022 22:11:51 +0100 Subject: [PATCH] added option to not register/unregister every start/stop but reuse a runner config instead --- README.md | 5 +++++ start.sh | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 58f2510..dee5002 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ The container expects the following environment variables: `CONCURRENT` - Limits how many jobs can run concurrently (default 1) +`UNREGISTER_ON_EXIT` - set this in case you want to unregister the runner on container stop (default not set) + +`REGISTER_ON_ENTER` - set this in case you want to register the runner on container start (default not set) + ### [Openstack variables](https://docs.openstack.org/python-openstackclient/latest/cli/man/openstack.html#environment-variables) `OS_AUTH_URL` - Openstack authentication URL @@ -108,6 +112,7 @@ Run a container: podman run -it \ -e PRIVATE_KEY="$(cat )" --env-file=env.txt \ + -v ~/runner.toml:/home/gitlab-runner/.gitlab-runner/config.toml quay.io/redhatqe/openstack-gitlab-runner:latest ``` diff --git a/start.sh b/start.sh index d840fb0..b2e50ca 100644 --- a/start.sh +++ b/start.sh @@ -3,7 +3,11 @@ trap cleanup 1 2 3 6 cleanup() { - gitlab-runner unregister --all-runners + if [[ "$UNREGISTER_ON_EXIT" ]]; then + gitlab-runner unregister --all-runners + else + gitlab-runner stop + fi sleep 5 } @@ -14,12 +18,16 @@ fi echo "$PRIVATE_KEY" > "$HOME"/priv_key +if [[ "$REGISTER_ON_ENTER" ]]; then gitlab-runner register --non-interactive \ --executor=custom \ --custom-config-exec="$HOME"/config.sh \ --custom-prepare-exec="$HOME"/prepare.py \ --custom-run-exec="$HOME"/run.py \ --custom-cleanup-exec="$HOME"/cleanup.py +else + gitlab-runner start +fi if [[ "$CONCURRENT" ]]; then sed -i "s/concurrent = .*/concurrent = $CONCURRENT/g" "$HOME"/.gitlab-runner/config.toml