Skip to content

how to deploy multiple servers with shell executor

please help me.

[our servers]

  • server1
  • server2
  • server3

I register gitlab-runner in these servers with shell executor. And I want to simple deploy to these servers.

So, my gitlab-ci.yml is below.

stages:
  - deploy

server1_deploy:
  stage: deploy
  tags:
    - server1
  script:
    - pwd
    - origin=$(pwd)
    - cd /path/to/dir
    - \cp -rf "${origin}/." .
    - git branch -D development
    - git checkout -b development

server2_deploy:
  stage: deploy
  tags:
    - server2
  script:
    - pwd
    - origin=$(pwd)
    - cd /path/to/dir
    - \cp -rf "${origin}/." .
    - git branch -D development
    - git checkout -b development

server3_deploy:
  stage: deploy
  tags:
    - server3
  script:
    - pwd
    - origin=$(pwd)
    - cd /path/to/dir
    - \cp -rf "${origin}/." .
    - git branch -D development
    - git checkout -b development

I push and after merge my request, jobs cannot work parallel. When Server1 job run, Server2 and Server3 jobs failed with The deployment job is older than the previously succeeded deployment job, and therefore cannot be run message. And after success Server1 job, I run Server2 job, Server2 job will run and success and 3 is same.

What is bad? Is it bad usage?

please help and sorry my poor English.