停止在并行Gitlab CI中运行作业

时间:2020-07-29 16:51:32

标签: continuous-integration gitlab gitlab-ci pipeline jobs

有什么方法可以停止在gitlab CI中并行运行的作业吗? 我的gitlab-ci.yml文件是:

image: google/cloud-sdk:slim

stages: 
  - deploy

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

deploy_website:
  stage: deploy
  script:
    - sed -i -e 's/https:\/\/us-central1-ahinko-website.cloudfunctions.net\/send_contact'/$GOOGLE_CLOUD_FUNCTION_EMAIL_URL'/g' src/client-side/js/custom-script.js
    - gsutil -m rm $GOOGLE_CLOUD_BUCKET/**
    - gsutil -m cp -R src/client-side/* $GOOGLE_CLOUD_BUCKET
  environment:
    name: $ENVIRONMENT

deploy_cloud_function: 
  stage: deploy
  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
  when: on_success
  environment:
    name: $ENVIRONMENT

两者都是并行运行的,我不希望这样。 jobs running in parallel

1 个答案:

答案 0 :(得分:1)

使用阶段:它们将按照stages声明中定义的顺序执行。

image: google/cloud-sdk:slim

stages: 
  - deploy
  - cloud

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

deploy_website:
  stage: deploy
  script:
    - sed -i -e 's/https:\/\/us-central1-ahinko-website.cloudfunctions.net\/send_contact'/$GOOGLE_CLOUD_FUNCTION_EMAIL_URL'/g' src/client-side/js/custom-script.js
    - gsutil -m rm $GOOGLE_CLOUD_BUCKET/**
    - gsutil -m cp -R src/client-side/* $GOOGLE_CLOUD_BUCKET
  environment:
    name: $ENVIRONMENT

deploy_cloud_function: 
  stage: cloud
  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
  when: on_success
  environment:
    name: $ENVIRONMENT