Reputation: 120
I have a gitlab CI configured to build and deploy code to 3 different servers with just minor changes before deploying each. Before deploying, I edit some files based on the server they are being deployed and push to the same repo from the CI pipeline. For this purpose, I want to use 3 different runners to run in order to build and deploy the code to each server but couldn't find how to do it. I can make each job in pipeline to run in parallel (using parallel matrix) on multiple runners, but the order in which the jobs run (i.e. execute 1 job first on all runners), the changes will not persist till the deploy job.
Is there a way I can trigger multiple runners to execute same job? or is their a workaround.
Upvotes: 0
Views: 1693
Reputation: 2250
I'm not sure I completely understand the question, but I think you're missing stages
.
You can define your stages like this in your .gitlab-ci.yml
(you can name them however you want):
stages:
- build
- test
- deploy
This way, the pipeline will wait until all build
jobs finish before it will run the test
jobs.
Now, you have to specify in which stage a job should execute:
build_job_1:
variables:
NODE_OPTIONS: --max_old_space_size=8192
GIT_CLEAN_FLAGS: none
stage: build
tags:
- runner1
build_job_2:
variables:
NODE_OPTIONS: --max_old_space_size=4096
stage: build
tags:
- runner2
Upvotes: 0
Reputation: 175
Define unique tags for each of your runners (ex. deploy-win11
, deploy-rhel8
, deploy-solaris
).
Create a template job and three jobs (each for one target system) that extends the template job. Then define required tags for each of these three jobs.
Enjoy success, where each job runs on its own specific runner, deploying the correct version of your software.
Upvotes: 0