How to multiple runner to deploy

Hello. all.

I registered two gitlab-runners in one project.
When I run the pipeline, only one gitlab-runner is distributed.
Is it not possible to distribute to multiple gitlab-runners?
I need your help.

This is my .gitlab-ci.yml below:

    - server/node_modules/

  - deploy_api

  stage: deploy_api
    - dev
    - deploy-dev
    - pwd
    - cd server
    - pwd
    - npm install
    - npm run pm2

Regards, David.

There is only one job in that .gitlab-ci.yml file, and any job will only run on one runner.

If you have more jobs they will be distributed.

If what you want is not actually distribution (spreading the load across servers) as much as duplication (getting the job run on multiple servers), you’ll either need to make one job that does the job on all servers or multiple jobs that each does the job on one server (and use different tags to make them picked up by different runners. I’m not the expert on that, but it’s mostly a question about what you want to parallelise the process and how much work you want when you change the set of servers that your stuff needs to be deplyed to.

Thank you for reply.

I got it and I’lll try.

Thank you again.

Regards, david.

Hi, you can use tags to select runners so that jobs can be run on multiple runners.

For example, assume you have two runners,

  • runner1, with tag r1-t
  • runner2, with tag r2-t

If you want a job named job_do_on_all_nodes to run on both runner, you might do this in .gitlab-ci.yml

    - r1-t
   - <do something>

    - r2-t
   - <do something>

This works for me. Hope to be helpful.