Job-Specification

---
key: deploy-to-zhdk-leihs-demo
name: Deploy to zhdk-leihs-demo.ruby.zhdk.ch
context:
  tasks:
    deploy:
      key: deploy
      name: deploy
      traits:
        g2016: true
      scripts:
        deploy:
          body: |
            set -eux
            cd deploy
            export ANSIBLE_HOST_KEY_CHECKING=False
            ansible-playbook demo-deploy_play.yml \
              --ssh-common-args '-i ~/.ssh/zhdk_ci_executor_rsa' \
              -i ../zhdk-inventory/${DEPLOY_TARGET_INVENTORY}
          timeout: 30 Minutes
        attach-server-log:
          body: |
            set -eux
            cd deploy
            export ANSIBLE_HOST_KEY_CHECKING=False
            ansible-playbook get-server-log_play.yml \
              --ssh-common-args '-i ~/.ssh/zhdk_ci_executor_rsa' \
              -i ../zhdk-inventory/${DEPLOY_TARGET_INVENTORY}

            echo ''; echo ''; echo '';
            echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            echo 'Last 100 lines of server log can be found in Trial Attachments!'
            echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          start_when:
            after deploy:
              states:
              - passed
              - aborted
              - defective
              - failed
              script_key: deploy
          ignore_abort: true
          ignore_state: true
      git_options:
        submodules:
          include_match: "^.*$"
      trial_attachments:
        server_log:
          content_type: text/plain
          include_match: ".*server_log.*"
      environment_variables:
        DEPLOY_TARGET_INVENTORY: demo-hosts
      exclusive_global_resources:
        zhdk-leihs-demo.ruby.zhdk.ch: true
priority: 2
run_when:
  nightly:
    type: cron
    rerun: true
    value: 0 3 * * *
    branch_include_match: "^master$"