Gitlab Ci运行一个接一个的作业



我有两个生产服务器,还有两个手动作业,现在我想运行第一个作业之后的第二个作业。我试着使用密钥:之后,需要但不工作

请告诉我如何在PROD_1作业完成后运行PROD_2作业,而不在第二个作业中使用when: manual

Deploy_Build_STAGE:
variables:
DEPLOY_DIR: "/var/www/my_stage_app"
environment:
name: STAGE
url: https://stage.example.com/
stage: Deploy
tags:
- stage
only:
- stage
script:
- preparing
- cd drupal/
- composer install -n --prefer-dist --ignore-platform-reqs --no-dev
- yarn install
- yarn build --no-progress
- copy_files -s "./" -d "$DEPLOY_DIR/public_html/"
- generate_drush_config
- cd $DEPLOY_DIR/public_html/web/
- drush cr
- drush updb -y
- drush cim -y
- drush updb -y
- drush cr
- sudo systemctl restart nginx php7.1-fpm varnish

Deploy_Build_PROD_1:
variables:
DEPLOY_DIR: "/var/www/my_app/"
environment:
name: PROD_1
url: https://example.com/
stage: Deploy
when: manual
#  allow_failure: false
tags:
- app1
only:
- new_prod
script:
- sudo systemctl stop nginx
- preparing
- cd drupal/
- composer install -n --prefer-dist --ignore-platform-reqs --no-dev
- yarn install
- yarn build --no-progress
- copy_files -s "./" -d "$DEPLOY_DIR/public_html/"
- generate_drush_config
- cd $DEPLOY_DIR/public_html/web/
- test -d sites/default/files/ || mkdir sites/default/files/
- drush cr
- drush updb -y
- drush cim -y
- drush updb -y
- drush cr
- sudo systemctl restart nginx php7.1-fpm varnish


Deploy_Build_PROD_2:
variables:
DEPLOY_DIR: "/var/www/my_app/"
environment:
name: PROD_2
url: https://example.com/
stage: Deploy
when: manual
tags:
- app2
only:
- new_prod
script:
#    - sudo systemctl stop nginx
- preparing
- cd drupal/
- composer install -n --prefer-dist --ignore-platform-reqs --no-dev
- yarn install
- yarn build --no-progress
- copy_files -s "./" -d "$DEPLOY_DIR/public_html/"
- generate_drush_config
- cd $DEPLOY_DIR/public_html/web/
- test -d sites/default/files/ || mkdir sites/default/files/
- sudo systemctl restart nginx php7.1-fpm varnish

要保留已执行作业的顺序,请在yaml中定义阶段,然后作业将以相同的顺序执行。

stages:
- first_stage
- second_stage
job_1:
stage: first_stage
...
job_2:
stage: second_stage
...

或者您可以使用按顺序执行的默认阶段:

stages:
- build
- test
- deploy

相关内容

最新更新