Gitlab Ci запускает одну работу после второй - PullRequest
0 голосов
/ 20 марта 2020

У меня 2 рабочих сервера и 2 ручных задания, и теперь я хочу запустить второе задание после первого. Я пытался использовать ключи: после, нужно, но не работает

Скажите, пожалуйста, как я могу запустить задание PROD_2 после выполнения задания PROD_1 и не использовать 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

1 Ответ

0 голосов
/ 20 марта 2020

Чтобы сохранить порядок выполненных заданий, задайте этапов в своем yaml, тогда задания будут выполняться в том же порядке.

stages:
  - first_stage
  - second_stage

job_1:
  stage: first_stage
...

job_2:
  stage: second_stage
...

или вы можете использовать этапы по умолчанию, которые выполняются по порядку :

stages:
  - build
  - test
  - deploy
...