4

My goal is to automatically register a shared Gitlab runner on our hosted Gitlab. To do this, I need to obtain the runners token via the Gitlab API.

Unfortunately, I haven't found a point in the API to fetch the shared runners token. On the website, the token is shown in Admin area / Overview / Runners / Set up a shared Runner manually.

As far as I know, Gitlab has 3 different types of runners token:

  • Specific (assigned to projects)
  • Group (assigned to a group)
  • Shared (for unassigned projects)

I am able to access the runners_token in the project details and the group details but I haven't found a place to obtain the shared runners_token.

I am thankful for every help!

1 Answers1

0

Without an API endpoint that supports this, here's an alternative solution. The command has to be run on the server hosting your Gitlab instance. The line below will output the current shared runner registration token.

sudo gitlab-rails runner -e production "puts Gitlab::CurrentSettings.current_application_settings.runners_registration_token"
trb
  • 120
  • 2
  • 12