0

I have a .gitlab-ci.yml file with two stages, and i would like to have that stages inside of a general stage called release. In other words i would like to have stage 1 and 2 inside of release. My .gitlab-ci.yml file is this:

 image: google/cloud-sdk:slim

stages: 
  - deploy-website
  - deploy-cloud-function 
 
before_script:
  - gcloud auth activate-service-account --key-file $GOOGLE_SERVICE_ACCOUNT_FILE
  - gcloud config set project $GOOGLE_PROJECT_ID

deploy-website:
  stage: deploy-website
  script:
    - gsutil -m rm gs://ahinko.com/**
    - gsutil -m cp -R src/client-side/* gs://ahinko.com
  environment:
    name: production
    url: https://ahinko.com
  only: 
    - ci-test

deploy-cloud-function: 
  stage: deploy-cloud-function
  script:
    - gcloud functions deploy send_contact --entry-point=send_contact_form --ingress-settings=all --runtime=python37 --source=src/server-side/cf-send-email/ --trigger-http
  environment: 
    name: production
    url: https://ahinko.com
  only:
    - ci-test

1 Answers1

0

To achieve what you want you just need to use the same stage name like

 image: google/cloud-sdk:slim

stages: 
  - release
 
before_script:
  - gcloud auth activate-service-account --key-file $GOOGLE_SERVICE_ACCOUNT_FILE
  - gcloud config set project $GOOGLE_PROJECT_ID

deploy-website:
  stage: release
  script:
    - gsutil -m rm gs://ahinko.com/**
    - gsutil -m cp -R src/client-side/* gs://ahinko.com
  environment:
    name: production
    url: https://ahinko.com
  only: 
    - ci-test

deploy-cloud-function: 
  stage: release
  script:
    - gcloud functions deploy send_contact --entry-point=send_contact_form --ingress-settings=all --runtime=python37 --source=src/server-side/cf-send-email/ --trigger-http
  environment: 
    name: production
    url: https://ahinko.com
  only:
    - ci-test

but if you do it your jobs will start at the same time. To avoid this behaviour you need to change the jobs to start manually

when: manual
Sergio Tanaka
  • 997
  • 1
  • 4
  • 17