我有一个带有两个阶段的.gitlab-ci.yml文件,并且我希望将这些阶段包含在称为release的一般阶段中。换句话说,我想在发布中包含阶段1和2。我的.gitlab-ci.yml文件是这样的:
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
答案 0 :(得分:0)
要实现您想要的目标,您只需要使用相同的阶段名称,例如
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
但是,如果您这样做,您的工作将在同一时间开始。 为避免这种情况,您需要将作业更改为手动启动
when: manual