How to configure multiple manual, parallel jobs?

Viewed 1472

I have an app with a pipeline setup like so:

Figure A

Figure A - 2 stage pipeline

With a .gitlab-ci.yml file like this

stages:
  - test
  - deploy

test:
  script:
    - bash run_tests.sh

deploy_staging:
  stage: deploy
  script:
    - rsync -rltvz --delete -e ssh --exclude=.git* public/ user@staging_node:/path/to/directory
  environment:
    name: staging
    url: https://staging.app.example.com
  only:
    - master

deploy_production:
  stage: deploy
  script:
    - rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node1:/path/to/directory
    - rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node2:/path/to/directory
  environment:
    name: production
    url: https://app.example.com
  when: manual
  only:
    - master

I have another app that I want to deploy similarly, but I want to make use of parallel jobs, like so:

Figure B

Figure B - 3 stage pipeline

In Figure A, deploy_production is a manual step (e.g. rsync a directory to multiple server nodes); in Figure B deploying to deploy_node1 and deploy_node2 would be a single step (e.g. something much more clock-time intensive than rsync), manually triggered through the Gitlab UI.

How can I configure .gitlab-ci.yml to run the deployment jobs in parallel while still maintaining a 1-click, manual deployment?

Update (response to Jakub Kania's answer):

Is this kind of what you had in mind, Jakub?

Attempting to use triggers, leads me towards this .gitlab-ci.yml:

stages:
  - test
  - stage
  - deploy

test:
  script:
    - bash run_tests.sh

staging:
  stage: stage
  script:
    - rsync -rltvz --delete -e ssh --exclude=.git* public/ user@staging_node:/path/to/directory
  environment:
    name: staging
    url: https://staging.app.example.com
  only:
    - master
  except:
    - triggers

deploy_trigger:
  stage: deploy
  script:
    - "curl -X POST -F token=TOKEN -F ref=master https://gitlab.example.com/api/v4/projects/1234/trigger/pipeline"
  environment:
    name: production
    url: https://app.example.com
  only:
    - master
  except:
    - triggers
  when: manual

deploy_node1:
  stage: deploy
  script:
    - rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node1:/path/to/directory
  environment:
    name: production
    url: https://app.example.com
  only:
    - master
    - triggers

deploy_node2:
  stage: deploy
  script:
    - rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node2:/path/to/directory
  environment:
    name: production
    url: https://app.example.com
  only:
    - master
    - triggers
1 Answers
Related