Register one runner to multiple projects

Is there a way to register a runner with multiple projects from the command line? As in, I am running gitlab-runner register --non-interactive --locked=false …, and I want the runner to become immediately available to start builds on multiple projects (whose registration tokens I have on hand), without having to go into the web UI for those projects and click on “Enable for this project”.

(I know I can register multiple runners, one per project, but I would prefer to register a single runner for multiple projects.)

Hello airbormemint, Did you ever recieve a solution to this? I am looking for the same thing.

I ended up writing a script that runs gitlab-runner register multiple times; there is no way to do it with a single invocation of gitlab-runner.

Thank you. I do see that even though I was able to register 2 runners and I can see them in my config.toml, it still does not pick up the jobs from the second project. Is that why you needed to write a script? If yes, do you have any suggestions on where to get help writing the script?

Thanks again,

The first thing that I would check would be whether the 2nd project sees the runner and thinks it’s active. If you go to the 2nd project’s CI/CD settings and look under runners, you will see a section called “Specific runners”, and your runner should be listed under “Runners activated for this project”. If it appears there at all, then registration was successful. If it has a green dot next to its name, then GitLab thinks that the runner is active. Let me know what you see in there and we’ll go from there.

Just got it working. Thank you for your quick reply as well.
So, yes, the runner was recognized. But since there were 2 runners listed in “Specific Runners”: 1) the original one from a original agent and then 2) the one I added. It was not immediately obvious which was associated with my new agent until I compared the number next to the green dot with the first part of the token from the config.toml - [[runners]] - token.
What made things start working was:

  1. I removed the newly added runner listed in “Specific Runners”.
  2. Then changed the token number in the config.toml to match thetoken from the original (and single remaining) runner in “Specific Runners”.
  3. I got that pull token number by clicking on the edit icon in the “Specific Runners” area across from the green dot.

Cool, I wouldn’t have guessed that so I’m glad you were able to figure it out :slightly_smiling_face:

Hello airbornemint, i was looking for the same thing and had some trouble writing the script. If you dont mind can you show me your script?