Create a "GitLab Runner Registration Token" (the new method for 16.x+)

I am trying to create a gitlab runner token “the new way” as it is also mentioned here: Deprecation of the GitLab Runner Registration Token - YouTube

Of couse I know how to use the mouse and I know how to click.

I would love to use the CLI using the gitlab-rails console.

Unfortunately the documentation for that isn’t yet update for the Registration Token version.

Any Idea where I can start?

Any progress here?

I haven’t tried to see what can be done using the rails console, but if you have a personal access token with api access for a user with admin privileges it’s quite easy.

(The following is based on some notes I made when I tried)

It’s just two commands that you have to execute on the new runner server.
With the gitlab server on 10.0.3.103:

curl -k -H 'Private-token: <token>' -X POST 'http://10.0.3.103/api/v4/user/runners?runner_type=instance_type&description=Kitchentest&paused=true&tag_list=test'

This will create a token for registering a runner and return it in a JSON structure, I don’t remember what else is in there, but it’s quite easy to find,

gitlab-runner register --non-interactive --url http://10.0.3.103 --token glrt-MzPEy3ACVVTy-DxzCHnh --name NI_test_i_kitchen --executor shell

(That token is what was returned by the previous command, and I don’t remember what NI meant when I did that test, “i” is danish for “in”, and “kitchen” is the test framework I used for that)

2 Likes

I returned to that and just though that I would show the output from a command like the first one I gave:

{"id":5,"token":"glrt-cK4NCWkPCEV2Pe79eR3L","token_expires_at":null}

it’s hardly necessary to format that piece of JSON nicely, I guess anybody can see what is there, and how to find the registration token in there.

1 Like
curl -k -H 'Private-token: <token>' -X POST 'http://10.0.3.103/api/v4/user/runners?runner_type=instance_type&description=Kitchentest&paused=true&tag_list=test'

That did the trick.

Thank you very very much!

Hi I was trying to use the new way of registering Runner using a personal access token but it is giving me the following issue
sudo gitlab-runner register --non-interactive -u “https://gitlab.com/” -r “$RUNNER_TOKEN" --executor “shell” --tag-list “runner” --description “Runner”
0.378 Runtime platform arch=amd64 os=linux pid=18 revision=782c6ecb version=16.9.1
0.381 Running in system-mode.
0.381
0.387 Created missing unique system ID system_id=*
0.387 WARNING: Support for registration tokens and runner parameters in the ‘register’ command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see Migrating to the new runner registration workflow | GitLab
0.875 ERROR: Registering runner… forbidden (check registration token) runner=glpat-** status=POST https://gitlab.com/api/v4/runners: 403 Forbidden (403 Forbidden - invalid token supplied)
0.875 PANIC: Failed to register the runner.

How can I resolve the issue??? if I tried to register using the runner token it is getting registered without any issue
Can I also know what is that 10.0.3.103