Skip to content

GitLab-CI promotion/deploy between environments

Hello,

First of all thank you for your best work!

I have a question regarding GitLab-CI

Is it possible promote packages from one environment only to the next one? (and not from the first to last directly, I hope this make sence)

Right now if I define more than 2 environments, I can deploy from the first on directly to the last one. I want to forbid this behaviour. And if possible I only want to move/promote the packages from one environment directly and only to the next one.

Here is example with 3 environments defined:

commit => SIT => UAT => PRO

Legend:

SIT => System Integration Testing

UAT => User Acceptance Testing

PRO => Production

In this example I want packages from SIT to be deployed/promoted only to UAT, and then from UAT only to PRO. I hope this make sence!

Here is my .gitlab-ci.yml file

stages:
  - build
  - deploy_sit
  - deploy_uat
  - deploy_pro

build:
  stage: build
  script:
  - echo "Installing dependencies..."
  - npm install
  - echo "Making build..."
  - npm run build

deploy_sit:
  stage: deploy_sit
  environment:
    name: SIT
    action: stop
  only:
  - master
  script:
  - echo "Deploying..."
  - aws s3 cp ./ s3://my-bucket/SIT/folder/ --recursive --exclude "*" --include "index.js"

deploy_uat:
  stage: deploy_uat
  environment:
    name: UAT
  only:
  - master
  when: manual
  script:
  - echo "Deploying..."
  - aws s3 cp ./ s3://my-bucket/UAT/folder/ --recursive --exclude "*" --include "index.js"

deploy_pro:
  stage: deploy_pro
  environment:
    name: PRO
  only:
  - master
  when: manual
  script:
  - echo "Deploying..."
  - aws s3 cp ./ s3://my-bucket/PRO/folder/ --recursive --exclude "*" --include "index.js"

I am open for any questions and thanks in advanced!