How does a shared runner work?

When I create a runner for a project and go to the next project, there is a button called Enable for this project. Can I use this button instead of creating a runner for each project? Is this the same as if I made a runner for each project?

Thank you.

Yes, you can share runners across multiple projects just be careful that the runner is not permanently setting variables or installing things that could conflict with another project. My favorite way of doing this is with tags on the pipeline code.

Be aware that if you don’t use tags you have to enable a setting in your runner telling It to run untagged jobs.

1 Like

Thank you so much for your reply.
I have defined a tag for each project in its .gitlab-ci.yml file.
Is there a problem if I create a runner for each project?

No, it’s just excessive. You could have 20 python projects and only need one or two runners to handle all their builds.

You could have 20 different runners but when an update rolled out you would need to update all of them.

Most of the time you can do things to make a build able to use a shared runner. For example if you need a specific environment variable during build, you can set that in the yaml file or in the project settings if it needs to be a secret. If its something like you need a different OS or hardware then you have to have different runners.

It depends a bit on the type of runner:

  • If you create a docker based runner, the filesystem including installed packages and login configuration you created will usually be reset with every new job. So installing packages and logins have to be repeated every time you start a pipeline resp. job.
  • A shell based runner on the other hand for better or worse keeps installed SDKs and logins . So you may gain speed advantages but pipelines of different projects or even parallel jobs of a single pipeline may interfere with each other.

You could create a docker image with all those packages and logins already included. Store it in your local gitlab registry so no one else can access it.