Multiple extends or multiple stages?

Hello,

I want to have a CI to deploy two commands (“bash X” and “bash Y”) on different production servers (server 1, server 2, server 3, etc.).

I don’t know how to do it : I tried with multiple extends but it only takes the last one (bashB) in my pipeline.

stages:
  - get_password
  - bashA
  - bashB

get_password:
  stage: get_password

# Steps

.bashA:
  stage: bashA
  script:
    - lorem ipsum
  when: manual
  only:
    changes:
      - script/bashA.sh

.bashB:
  stage: bashB
  script:
    - ipsum loreem
  when: manual
  only:
    changes:
      - script/bashB.sh

# SRV1
deploy-srv1:
  extends: 
    - .bashA
    - .bashB
  variables:
    SRV_1: urlsrv1

# SRV2
deploy-srv2:
  extends: 
    - .bashA
    - .bashB
  variables:
    SRV_1: urlsrv2

I looked for multiple stages but it don’t seems to answer my question.
I don’t really care if it runs in parallel or B after A. (the manual section is for debugging)
I just want to be able to deploy bashA and bash B on X servers (I just took 2 servers for example).

Could you help me, please ?
Thank you !!

One way is to use 1 runner and let the scripts ssh to other servers, something like:

ssh -t user@server1 bash X
and
ssh -t user@server2 bash Y

But better might be, if both servers have a runner installed and have a tag associated. You can then add the tag to the job/stage and it will be executed by that runner. Also see https://docs.gitlab.com/ee/ci/yaml/#tags As the runner can execute stuff on the server, I would limit the project access to those runners.

I think step A does not get executed, because it only gets executed when script/bashA.sh has been changed.

Okay, thank you.

I’ve got only one runner and access to X servers it’s not a problem because when I say bash, instead, it’s like a CURL command that I have to do, my bad. And when I make the step “get_password”, I already solve the problem of getting access to the server.

The real problem here is that I have two jobs that I want to trigger only if there is a change in their respective file. And each job needs to be deployed on a different environment.
Maybe it’s not possible to do this thing in a single pipeline… (multiple jobs and multiple variables)

btw that last line of your ci file shouldn’t that be:

    SRV_2: urlsrv2

instead of

    SRV_1: urlsrv2

?