language: java
sudo: true
jdk:
  - oraclejdk8
install: true
services:
  - docker
git:
  depth: 9999
  quiet: true
addons:
  sonarcloud:
    organization: "dadoonet-github"
#before_install:
#  - sudo apt-get -qq update
#  - sudo apt-get install -y tesseract-ocr
before_script:
  - sudo sysctl -w vm.max_map_count=262144
script:
  - mvn --batch-mode clean verify -Pes-5x
  - mvn --batch-mode clean verify -Poss
  - "[[ ${TRAVIS_SECURE_ENV_VARS} == 'true' ]] && mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar"
after_success:
  - "[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] && [[ ${TRAVIS_TAG} == '' ]] && mvn deploy -DskipTests --settings deploy-settings.xml"
cache:
  directories:
    - '$HOME/.m2/repository'
    - '$HOME/.sonar/cache'
branches:
  only:
    - "master"

language: java
sudo: true
jdk:
  - oraclejdk8
install: true
services:
  - docker
git:
  depth: 9999
  quiet: true
addons:
  sonarcloud:
    organization: "dadoonet-github"
#before_install:
#  - sudo apt-get -qq update
#  - sudo apt-get install -y tesseract-ocr
before_script:
  - sudo sysctl -w vm.max_map_count=262144
script:
  - mvn --batch-mode clean verify -Pes-5x
  - mvn --batch-mode clean verify -Poss
after_success:
if [ "$TRAVIS_SECURE_ENV_VARS" = true ]; then
   mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
fi
if [ "$TRAVIS_PULL_REQUEST" = false ] && [ "$TRAVIS_TAG" = '' ]; then
  mvn deploy -DskipTests --settings deploy-settings.xml
fi
cache:
  directories:
    - '$HOME/.m2/repository'
    - '$HOME/.sonar/cache'
branches:
  only:
    - "master"

Move SonarCloud run in the after_success part
Move SonarCloud run in the after_success part

As a script so we can easily skip it without failing the build for PR.
