First, understand why you want multiple runners. If you just want multiple jobs to run in parallel, the builtin executors will respect the concurrent
configuration and allow execution of multiple jobs in parallel. Generally, you only need one runner process and one config file per host. This process can handle multiple runner configurations at the same time.
If you want multiple runners with different configurations (e.g., have a shell executor runner and a docker executor runner side-by-side), you can add multiple runner sections to the config file; just add another [[runner]]
section to the config.toml
!. If you call the register
command multiple times, it will do this for you. Each runner will show up as a separate registered runner in the GitLab UI, but you only need one config and one gitlab-runner
process to manage multiple registered runners in concert.
For example, a config with two separately configured executors you would run gitlab-runner register
twice with different arguments for a different resulting configuration.
Start with a config file with just the global elements or other non-runner sections defined. Something like this:
concurrent = 10
check_interval = 0
# ... etc...
[session_server]
session_timeout = 1800
Then register the runners you want with configuration keys passed by command line (or you can edit configuration in config.toml
after registering each runner):
# register the first runner
gitlab-runner register \
--non-interactive \
--url "https://${HOSTNAME}/" \
--registration-token "${REGISTRATION_TOKEN}" \
--executor "docker" \
--tag-list "docker" \
--run-untagged="true" \
--config="/etc/gitlab-runner/config.toml"
# ... etc
# register the second runner
gitlab-runner register \
--non-interactive \
--url "https://${HOSTNAME}/" \
--registration-token "${REGISTRATION_TOKEN}" \
--executor "shell" \
--tag-list "shell" \
--limit="2" \
--config="/etc/gitlab-runner/config.toml"
# ... etc
Notably --tag-list
must be provided at the time of registration. After registration, this can only be edited in the GitLab UI or via the API.
After running the register commands, this should result in your config.toml being edited with two [[runners]]
sections. It would look something like this:
concurrent = 10 # global/total concurrency
check_interval = 0
# ... etc...
[session_server]
session_timeout = 1800
# Specify a docker executor
[[runners]]
(...) # specific runner config, token, etc.
executor = "docker"
[runners.docker]
(...) # docker executor configuration...
# specify a shell executor
[[runners]]
(...) # specific runner config, token, etc.
executor = "shell"
limit = 2 # concurrency limit for THIS executor
When you run gitlab-runner start
you should see two runners online in the GitLab UI
concurrent
setting in the config. – Phebe