Michael Gruben
Michael Gruben

Reputation: 56

Gitlab-Runner Deploy to multiple servers

I got following environment and setup:

How can I achieve:

The question is based on my current setup where following questions came up

or is there another solution which lets me achieve my plans?

Upvotes: 2

Views: 7179

Answers (1)

Stefan van Gastel
Stefan van Gastel

Reputation: 4478

"Can I let a gitlab-runner run just locally (also not in a docker container because I havn't installed one) so that its just up to the gitlab-ci.yml to differ on branches and deploy to the specific servers"

Yes, register local runners as specific runners with Shell executors on the machines you want to deploy to so they can run local commands just like you use SSH now and only your specific projects can use them. Then take a look at the next sub-answer regarding tags.

"Can I install multiple gitlab-runners which are taking aktion on just specific branches?"

Use either tags to pin certain jobs to runners (e.g. your deploy job) or use only or except to pin jobs to branches or tags. (e.g. your deploy_prod job only run on master branch)

Example .gitlab-ci.yml file (abstract):

deploy-dev:
  tags: 
    - dev-runner
  only: 
    - dev-branch
  script:
    - cd mydir
    - git pull

deploy-prod:
  tags: 
    - prod-runner
  only: 
    - master
  script:
    - cd mydir
    - git pull

Upvotes: 6

Related Questions