language: java
jdk:
  - oraclejdk8

sudo: required
install:
  - sudo apt-get update
  - sudo apt-get install lib32ncurses5 lib32z1 -y

notifications:
  webhooks:
    urls:
      - "https://scalar.vector.im/api/neb/services/hooks/dHJhdmlzLWNpLyU0MGFsZXglM0FtYXRyaXguZWxhb24uZGUvJTIxdWpSeXlUSGxQcXlRb2prcG1vJTNBbWF0cml4LmVsYW9uLmRl"
    on_success: change  # always|never|change
    on_failure: always
    on_start: never

#Sonar
addons:
  ssh_known_hosts:
    - mediathekview.de
  sonarcloud:
    organization: "mediathekview"
    token:
      secure: woV09cAHTwbI9/oyQs1WtA3oU9dhftuFrJ4pNGOec0sszwkQLzU+G5JGmnoOSt26ZB9tE8Cd5RuWFXlq6QA89ml1uuvxmSk0rX7srNbLaDUQu1Oe0467emeAeZLu87Z2DP6ylu32Gz6daOpG4St4z8MbJbT7cXBQ8PnNUv7T120NM9NPzBqGORqPYKrVsIwtAtrVFm5l5uUCCdS7E53jhv2GgmKGwSE4EWggCZF6c8AMfJV5bRNRG5sfClekrWkNSjqxoihNTlh8VBtkPOCiCB4+OtubeYuLXLi5WcoU6XYRzHu9BiunC5lJhKtAjjSYnkEswpOiYRZFBNEnUPR72gWujZELVl2jv8q8flQp9xBAH7eTIXvaR56WI/Bj9UvjUJiPDgJRl1TfBDlinEIOWbThI6GE2fuQoZqBihMCf0VNHg261UMf6bb7KFJwjtodM9yu12rekTmvI02vpSFE8877m+xXeDcGJCuBnrgXp95BPUsg72vCoe6x9obOLNe+VxEpan2KDqCcozM4X5LtRKBdnzTmHJuVB7LWb8+UpuhI+sf58DZOBPGYF79o5SK9dG0mo3qgl9dMFPaduxh25/DEZP/QgA+1s8b6n/1P5enY7zt/r14qSEIifTXuw4Jk1AkcyfUMso9Y87X7Bv5U7xoeVn9H6ZiP4QRLlDQS6jo=
    github_token:
      secure: moMQ5jINxm27QvSKiH8R5C8w1qj4GHF/tsO33GFAqYiOyoQbEVtGqGq5z9a7/O4ShfYItAIgMO1qLqmu4l+nnvkat/v3VGiuj3E4RXWxbfx9C7uY20eZbxWyUW7XX4PsUAl+WNfHipHulk5j+YbCGQpktJ+ieVm/iD3J4acIuio3Ty6QrCltwpHVMjdTWlj4vLitK08O0ZtmUzwNU3O89qLsCNR9TCsX7vgeDP5DUtY3BivFDgHo+1+6Ci7fcEayeArLNSrWFlvJcxMf3qq8JxABRrTzDuSG4y7hC7Kf8VBeQnpRBvIF6YpHTN6nv1uZ3y6Oj+w/gTBEHGMOjWMFK8EJjA+eT02Wsmhfxk3blAyPrDtqG2uLXi6DWJob5cj/25SdFvRXtkwWg7RFP+FZ7O5I+TxtWV51Ss7PoUJs+cKBS04c1trpzX68ltLgz3X9cj3Sg4gvovaKX10kVLQhQdIsstXed1A6fy8MtrgAecHhN6saALSbawYR9PqAngrPSIexa8tITVz/cM/7IimZnm7zAFVRkTozgKzmnc3FMvgfiwkqjfgztty2x5keslNEyrwlNKOrQKnJveQmjGKgYpV+OwHAWxIbdBLNDcnzu/IqoVlPQ2u6aosFw5cG5+Q63ng26P4vcU67+ObBbw+hgRG621AG0a6RqBzzWwDt9ew=
    branches:
      - master
      - develop
      - feature/.*
      - hotfix/.*

# Build
script:
  - ./gradlew check build
  - echo "Travis Event Typ '$TRAVIS_EVENT_TYPE' und letzer Commit '$TRAVIS_COMMIT'";
  - if [ "$TRAVIS_EVENT_TYPE" == "cron" ]; then openssl aes-256-cbc -K $encrypted_e4ced02e3beb_key -iv $encrypted_e4ced02e3beb_iv 
    -in scripte/deploy/deploy.key.enc -out scripte/deploy/deploy.key -d && scripte/deploy/deploy.sh nightly $TRAVIS_COMMIT; fi
after_success:
  - sonar-scanner

#Cache
before_cache:
  - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
  directories:
  - "$HOME/.gradle/caches/"
  - "$HOME/.gradle/wrapper/"
  - "$HOME/.sonar/cache/"
  
#Deploy
before_deploy:
  - openssl aes-256-cbc -K $encrypted_e4ced02e3beb_key -iv $encrypted_e4ced02e3beb_iv 
    -in scripte/deploy/deploy.key.enc -out scripte/deploy/deploy.key -d
deploy:
  - provider: script
    script: scripte/deploy/deploy.sh
    skip_cleanup: true
    on:
      branch: master
      tags: true
  - provider: releases
    api_key:
      secure: moMQ5jINxm27QvSKiH8R5C8w1qj4GHF/tsO33GFAqYiOyoQbEVtGqGq5z9a7/O4ShfYItAIgMO1qLqmu4l+nnvkat/v3VGiuj3E4RXWxbfx9C7uY20eZbxWyUW7XX4PsUAl+WNfHipHulk5j+YbCGQpktJ+ieVm/iD3J4acIuio3Ty6QrCltwpHVMjdTWlj4vLitK08O0ZtmUzwNU3O89qLsCNR9TCsX7vgeDP5DUtY3BivFDgHo+1+6Ci7fcEayeArLNSrWFlvJcxMf3qq8JxABRrTzDuSG4y7hC7Kf8VBeQnpRBvIF6YpHTN6nv1uZ3y6Oj+w/gTBEHGMOjWMFK8EJjA+eT02Wsmhfxk3blAyPrDtqG2uLXi6DWJob5cj/25SdFvRXtkwWg7RFP+FZ7O5I+TxtWV51Ss7PoUJs+cKBS04c1trpzX68ltLgz3X9cj3Sg4gvovaKX10kVLQhQdIsstXed1A6fy8MtrgAecHhN6saALSbawYR9PqAngrPSIexa8tITVz/cM/7IimZnm7zAFVRkTozgKzmnc3FMvgfiwkqjfgztty2x5keslNEyrwlNKOrQKnJveQmjGKgYpV+OwHAWxIbdBLNDcnzu/IqoVlPQ2u6aosFw5cG5+Q63ng26P4vcU67+ObBbw+hgRG621AG0a6RqBzzWwDt9ew=
    file_glob: true
    file:
      - build/distributions/*
    skip_cleanup: true
    on:
      tags: true
