Reputation: 41
I configured a specific runner for gitlab-ci on a local server. It worked like a charm, and it is 3 times faster that the shared runner on gitlab.com. So far, so great.
But I was wondering what will happen if my local server was not available. In this scenario, all the jobs of the pipeline will be in pending (waiting to the specific runner). If so, all projects deployments could be stuck for a while.
I tried some configurations in .gitlab-ci.yml to run the shared runner if my specific runner was not available. But all my tests failed.
My idea was to set 2 tags for the runners. The first one for my specific runner and the second one for the shared runner.
.tags: &tags
- my-custom-runner
- shared
But in this configuration, if my-custom-runner was not available, I had this error in the gitlab-ci job :
this job is stuck because you don't have any active runners
Has anyone figured out how to do this yet ? I didn't find related documentation on this topic.
Any help will be welcome. Thanks a lot.
This configuration works if my-custom-runner is available :
.tags: &tags
- my-custom-runner
This configuration works too and runs in the gitlab shared runner.
.tags: &tags
- shared
Upvotes: 4
Views: 744
Reputation: 9237
Where did you get the shared
tag from? The GitLab.com shared runners do not use a shared
tag.
saas-windows-medium-amd64
The configuring runners documentation defines the tag behavior between runner and job tags. (See also job tags
doc.)
For a runner to be selected to run a job, it must have all of the tags defined in the job script block.
I assume you can register your runner under the same tag name as the shared runners, and then configure the job to use that. Which tag that is depends on your target OS and architecture.
I don't see a way to specify on the job tags to use one tag or runner over the other. So if GitLab does not inherently prefers customer registered runners over shared runners, and you really want to implement the preference, you'll need a wrapper job that checks availability and distributes the job.
A somewhat wasteful alternative would be triggering the job on your own and a shared runner, and then early-cancel the other job when one of them finishes.
Upvotes: 0