Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -108,6 +112,7 @@ Run a container:
podman run -it \
-e PRIVATE_KEY="$(cat <private key filename>)"
--env-file=env.txt \
-v ~/runner.toml:/home/gitlab-runner/.gitlab-runner/config.toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this line is not necessary for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since I do not set UNREGISTER_ON_EXIT and REGISTER_ON_ENTER by default it makes perfectly sense to volume/persist the runner config by default.
This however depends on how you want to run it.

quay.io/redhatqe/openstack-gitlab-runner:latest
```

Expand Down
10 changes: 9 additions & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already gitlab-runner run command below. Moreover, gitlab-runner start requires root.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, there is no gitlab-runner run in the script but a gitlab-runner register this does execute register and start in one command. That is actually why I changed this with this changeset so you can start without register. Same goes for unregister.
You may have needed root if your mounted config file (volume) had incorrect permissions/owner on your system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, the last line containing gitlab-runner run was hidden in the changeset so i did not see it and not realize.
I am not exactly sure what the difference between start and run is. The man page and docs do not make this more clear to me. is start as service and run as foreground? or do you need to call bost? Maybe you can help me understand this better?
It did however work for me like this and I did not face a issue till now.
Also I can tell register/unregister is not what I want all the time.

fi

if [[ "$CONCURRENT" ]]; then
sed -i "s/concurrent = .*/concurrent = $CONCURRENT/g" "$HOME"/.gitlab-runner/config.toml
Expand Down