I have a repository in GitLab with two connected runners. Each runner is on a different server. Each runner has a test
tag.
Assuming my CICD pipeline is just one action:
deploy:
stage: deploy
tags:
- test
script:
- echo 'Deploying...'
How can I run it on both servers/runners at the same time?
Every job is executed on a single runner. You cannot run a single job on multiple runners.
Additionally, if all runners use the same tag, there's no guarantee of which runner will pick up the job. If you create multiple jobs, they may all be run by a single runner.
To ensure a job runs a specific runner, the runner needs a unique tag. To run jobs on all the runners, you'll need as many jobs as you have runners, each configured to use the respective unique tag.
So, if each of your runners had a unique tag like runner-1
, runner-2
, runner-3
, you might do something like this:
myjob-dev:
tags:
- runner-1
# ...
myjob-staging:
tags:
- runner-2
# ...
myjob-production:
tags:
- runner-3
# ...
You can condense the configuration using parallel:matrix:
or extends:
or similar techniques to optimize the configuration.