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.)
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?
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:
I removed the newly added runner listed in “Specific Runners”.
Then changed the token number in the config.toml to match thetoken from the original (and single remaining) runner in “Specific Runners”.
I got that pull token number by clicking on the edit icon in the “Specific Runners” area across from the green dot.