Exclude a runner from running jobs with specific tags
Description
As per my understanding of how gitlab runners work. We can create runners which can pick jobs only with specific tags. However, we would like to have a chance for a runner to skip a job if it has some tags.
For example, I have two runners namely
- job-runner - runs any jobs (can pick jobs without tags)
- lang-B-runner - runs Language B jobs(specified by tag
langB
)
And I have the concurrent runners enabled in my runner config.
Here, if there are two jobs which are having the tag langB, then one will be picked by the lang-B-runner and one by the job-runner. I want to prevent this. the lang-B-runner should only only pick the two jobs and wait for one to complete.
I know that I can make it work by setting the job-runner to run only langA tagged jobs. However, we have a huge codebase which is around 100+ repositories and we have very few (<5) langB jobs. It would be like we have to manually go and edit each repo's gitlabci file which is possible but is time consuming.
For now we are only using one project of langB in production so we have configured a specific runner for the same.
Will it be possible to create a runner that only picks jobs without specific tags.
Proposal
In .gitlabci I should be able to make the runner know that it should not pick jobs with specific tags.
image: docker:latest
tags:
langB
script:
echo "should run in lang-B-runner only"
It could possibly be something like below:
sudo gitlab-runner --url https://gitlab.example.com \
--exclude-tags ["langB"] \
--registration-token xxxxxxxxxxx \
--executor docker \
--description "job-runner" \
--docker-image "docker:stable" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock
I have searched for help in gitlab stackoverflow thread. However, I couldn't find anything that would match our case. Please let me know if there's a better way to do this.