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!