There isn't an easy way to do what you want, from what I can find in the GitLab documentation and some open issues that they have.

Here is an issue that describes something similar to what you want:

https://gitlab.com/gitlab-org/gitlab-runner/issues/3540

Here is what I think is GitLab's goal with how to register runners:

https://gitlab.com/gitlab-org/gitlab-ce/issues/40693

I believe that the only thing that you can't change from the .toml file is the name of the runner, and maybe not the tags either. Then name is only created when you register the runner. I read something somewhere that you can change the tags of a shared runner, but I can't find it now.

Here is a workaround to make the process of registering a bit more automatic:

https://gitlab.com/gitlab-org/gitlab-runner/issues/3553#note_108527430

He used this API:

curl --request POST "https://gitlab.com/api/v4/runners" --form "token=<registration-token>" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"

Then he got the following response back:

{"id":401513,"token":"<runner-token>"}

He could then inject the runner-token into his already pre-made .toml file.

For you, it would have been possible to use the registration token for your group, and then to write in the description/name of the runner and the tags. You could then have re-used your config.toml and only changed the runner-token, and it should have worked.

Answer from MrBerta on Stack Overflow
🌐
GitLab
docs.gitlab.com › runner › register
Registering runners | GitLab Docs
For runners on GitLab.com, the GitLab instance URL is https://gitlab.com. Enter the runner authentication token. Enter a description for the runner. Enter the job tags, separated by commas. Enter an optional maintenance note for the runner. Enter the type of executor. To register multiple runners on the same host machine, each with a different configuration, repeat the register command.
🌐
GitLab
docs.gitlab.com › runner › commands
GitLab Runner commands | GitLab Docs
GitLab Runner contains a set of commands you use to register, manage, and run your builds. ... Most of the commands support environment variables as a method to pass the configuration to the command. You can see the name of the environment variable when invoking --help for a specific command. For example, you can see below the help message for the run command: ... NAME: gitlab-runner run - run multi runner service USAGE: gitlab-runner run [command options] [arguments...] OPTIONS: -c, --config "/Users/ayufan/.gitlab-runner/config.toml" Config file [$CONFIG_FILE]
🌐
GitLab
docs.gitlab.com › runner
GitLab Runner | GitLab Docs
sequenceDiagram participant GitLab participant GitLabRunner participant Executor opt registration GitLabRunner ->>+ GitLab: POST /api/v4/runners with registration_token GitLab -->>- GitLabRunner: Registered with runner_token end loop job requesting and handling GitLabRunner ->>+ GitLab: POST /api/v4/jobs/request with runner_token GitLab -->>+ GitLabRunner: job payload with job_token GitLabRunner ->>+ Executor: Job payload Executor ->>+ GitLab: clone sources with job_token Executor ->>+ GitLab: download artifacts with job_token Executor -->>- GitLabRunner: return job output and status GitLabRunner -->>- GitLab: updating job output and status with job_token end
🌐
Cam
guidebook.devops.uis.cam.ac.uk › howtos › git-gitlab › register-a-gitlab-runner
Registering a Gitlab Runner - DevOps Division Guidebook
As a side effect of this, there might be a situation where runner is registered but the behaviour is changed (for example, runner starts to pick up the untagged jobs or tags are missing). That is why it is important to remember that now the configuration must be done before the registration, CLI options (as well as Helm values) will be ignored. ... gitlab-runner register \ --non-interactive \ --executor "shell" \ --url "https://gitlab.developers.cam.ac.uk/" \ --tag-list "shell,mac,gdk,test" \ --run-untagged "false" \ --locked "false" \ --access-level "not_protected" \ --registration-token "REDACTED"
🌐
GitLab
docs.gitlab.com › tutorials › automate_runner_creation
Tutorial: Automate runner creation and registration | GitLab Docs
After you create a runner and its configuration, you can use the same runner authentication token to register multiple runners with the same configuration. For example, you can deploy multiple instance runners with the same executor type and job tags to the target compute host.
🌐
Readthedocs
codechecker.readthedocs.io › en › latest › gitlab_integration
1. Install/register GitLab Runner - CodeChecker
sudo gitlab-runner register \ --non-interactive \ --url "https://mycompany.gitlab.com" \ --registration-token "<REGISTRATION_TOKEN_FROM_GITLAB>" \ --description "codechecker" \ --executor "shell"
🌐
GitLab
docs.gitlab.com › user › get_started › get_started_runner
Get started with GitLab Runner | GitLab Docs
You can configure GitLab Runners by editing the config.toml file, which is automatically generated when you install and register a runner. In this file you can edit settings for a specific runner, or for all runners. Configure it to set concurrency limits, logging levels, cache settings, CPU limits, and executor-specific parameters.
🌐
GitLab
forum.gitlab.com › how to use gitlab
GitLab Runner registration workflow - How to Use GitLab - GitLab Forum
March 20, 2023 - GitLab Runner need for each one own IP/Hardware? One thing with GitLab Runner I do not understand. Can I register one dedicated Runner (Hardware) to different Projects? As sample I have following Gitlab Runners gitlab-runner-1 gitlab-runner-2 gitlab-runner-shared-1 gitlab-runner-shared-2 gitlab-runner-1 is bound to project 1 with project token gitlab-runner-2 is bound to project 2 with project token Each runner is shown inside the project and on the left side the shared runners.
Find elsewhere
Top answer
1 of 3
15

There isn't an easy way to do what you want, from what I can find in the GitLab documentation and some open issues that they have.

Here is an issue that describes something similar to what you want:

https://gitlab.com/gitlab-org/gitlab-runner/issues/3540

Here is what I think is GitLab's goal with how to register runners:

https://gitlab.com/gitlab-org/gitlab-ce/issues/40693

I believe that the only thing that you can't change from the .toml file is the name of the runner, and maybe not the tags either. Then name is only created when you register the runner. I read something somewhere that you can change the tags of a shared runner, but I can't find it now.

Here is a workaround to make the process of registering a bit more automatic:

https://gitlab.com/gitlab-org/gitlab-runner/issues/3553#note_108527430

He used this API:

curl --request POST "https://gitlab.com/api/v4/runners" --form "token=<registration-token>" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"

Then he got the following response back:

{"id":401513,"token":"<runner-token>"}

He could then inject the runner-token into his already pre-made .toml file.

For you, it would have been possible to use the registration token for your group, and then to write in the description/name of the runner and the tags. You could then have re-used your config.toml and only changed the runner-token, and it should have worked.

2 of 3
0

A gitlab runner can be registered with multiple projects and/or groups. This will just append the configurations in /etc/gitlab-runner/config.toml (with sudo). Can we just do the following steps:

  1. Un-register the gitlab-runner associated with the "project"
  2. Register the the gitlab-runner associated with the "group"

config.toml stores all the configuration which is passed to gitlab-runner register including any environment variables which are listed under gitlab-runner register -h command.

I am not sure why do you need to save the config.toml.

Also, I believe one source of confusion could be gitlab-runner-token VS gitlab-runner-registration-token. The registration-token can NOT be used inside config.toml which may be the reason why you failed after just a replacement. If you do not want to use gitlab-runner register command and just update the config.toml then follow the steps defined in the above ans to fetch the gitlab-runner-token and use it in config.toml. We can then try and stop and start the gitlab-runner service using sudo service gitlab-runner stop and sudo service gitlab-runner start

🌐
GitLab
docs.gitlab.com › tutorials › create_register_first_runner
Tutorial: Create, register, and run your own project runner | GitLab Docs
July 5, 2023 - You must register the runner to link it to GitLab so that it can pick up jobs from the project pipeline. ... In the top bar, select Search or go to and find your project. Select Settings > CI/CD. Expand the Runners section. Select Create project runner. In the Tags section, select the Run untagged checkbox. Tags specify which jobs the runner can run and are optional...
🌐
GitLab
docs.gitlab.com › ci › runners › configure_runners
Configuring runners | GitLab Docs
The option to pass runner registration tokens and support for certain configuration arguments is considered legacy and is not recommended. Use the runner creation workflow to generate an authentication token to register runners. This process provides full traceability of runner ownership and ...
🌐
GitLab
docs.gitlab.com › ci › runners › new_creation_workflow
Migrating to the new runner registration workflow | GitLab Docs
The gitlab-runner register command accepts runner authentication tokens instead of registration tokens. You can generate tokens from the Runners page in the Admin area. The runner authentication tokens are recognizable by their glrt- prefix. When you create a runner in the GitLab UI, you specify configuration values that were previously command-line options prompted by the gitlab-runner register command.
🌐
GitHub
github.com › tobilg › gitlab-ci-runner-marathon › blob › master › docs › gitlab_runner_register_arguments.md
gitlab-ci-runner-marathon/docs/gitlab_runner_register_arguments.md at master · tobilg/gitlab-ci-runner-marathon
July 4, 2023 - docker run -it --name gitlab-runner gitlab/gitlab-runner:latest register --help · is this: NAME: register - register a new runner USAGE: command register [command options] [arguments...] OPTIONS: -c, --config "/etc/gitlab-runner/config.toml" Config file [$CONFIG_FILE] --tag-list Tag list [$RUNNER_TAG_LIST] -n, --non-interactive Run registration unattended [$REGISTER_NON_INTERACTIVE] --leave-runner Don't remove runner if registration fails [$REGISTER_LEAVE_RUNNER] -r, --registration-token Runner's registration token [$REGISTRATION_TOKEN] --name, --description "f3c40eb54139" Runner name [$RUNNE
Author   tobilg
🌐
GitLab
docs.gitlab.com › runner › configuration › advanced-configuration
Advanced configuration | GitLab Docs
GitLab Runner validates log options during executor preparation. If you specify unsupported options such as max-size, max-file, or compress, the job fails immediately with a configuration error. The log options apply to the main job container and any service containers defined in your CI/CD configuration. For more information about Docker logging, see the Docker json-file log driver documentation. To use private registries as a source of images for your jobs, configure authorization with the CI/CD variable DOCKER_AUTH_CONFIG.
🌐
Gitlab
gitlab-org.gitlab.io › gitlab-development-kit › howto › runner
Using GitLab Runner with GDK –GitLab Development Kit
2 weeks ago - To create and register a local runner for your instance: On the left sidebar, click on the Search or go to... button. Select Admin Area. On the left sidebar, select CI/CD > Runners. Select Create instance runner. In the Tags section, select the Run untagged checkbox. Tags specify which jobs the runner can run. Tags are optional, but if you don’t specify tags then you must specify that the runner can run untagged jobs.
🌐
GitLab
docs.gitlab.com › ci › runners
Runners | GitLab Docs
September 22, 2022 - A runner must first be registered with GitLab, which establishes a persistent connection between the runner and GitLab.
🌐
Medium
vineetcic.medium.com › registering-gitlab-runners-2f78703d024e
Registering GITLAB-Runners. Registering a Runner is the process… | by Vineet Kumar | Medium
July 30, 2021 - Make sure to restart the whole container instead of using gitlab-runner restart: docker restart gitlab-runner · One line Registration command with docker excecutor: docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register --non-interactive --executor “docker” --docker-image alpine:latest --url “https://mygiturl.com/" --tls-ca-file “/etc/gitlab-runner/certs/ca.crt -n” --registration-token “XXXXXXX” --description “docker-runner-MYFIRST-RUNNER” --tag-list “docker” --run-untagged=”true” --locked=”false” --access-level=”not_protected” --docker-privileged
🌐
GitLab
docs.gitlab.com › ci › runners › runners_scope
Manage runners | GitLab Docs
When you create a runner, it is ... use to register it. The runner uses the token to authenticate with GitLab when picking up jobs from the job queue. ... In the upper-right corner, select Admin. Select CI/CD > Runners. Select Create instance runner. Select the operating system where GitLab Runner is installed. In the Tags section, in the Tags field, enter the job tags to specify jobs the runner can run. If there are no job tags for this runner, select Run untagged. Optional...
🌐
GitLab
docs.gitlab.com › runner › configuration
Configure GitLab Runner | GitLab Docs
Learn how to configure GitLab Runner. Advanced configuration options: Use the config.toml configuration file to edit runner settings.
🌐
GitLab
docs.gitlab.com › runner › examples › gitlab.html
How to configure GitLab Runner for GitLab CE integration tests
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify ...