#!/bin/bash set -euo pipefail function installTravisTools { curl -sSL https://raw.githubusercontent.com/sonarsource/travis-utils/v2.1/install.sh | bash } case "$JOB" in H2) mvn verify -B -e -V -DforkCount=2 ;; POSTGRES) installTravisTools psql -c 'create database sonar;' -U postgres travis_runDatabaseCI "postgresql" "jdbc:postgresql://localhost/sonar" "postgres" "" ;; MYSQL) installTravisTools mysql -e "CREATE DATABASE sonar CHARACTER SET UTF8;" -uroot mysql -e "CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';" -uroot mysql -e "GRANT ALL ON sonar.* TO 'sonar'@'localhost';" -uroot mysql -e "FLUSH PRIVILEGES;" -uroot travis_runDatabaseCI "mysql" "jdbc:mysql://localhost/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance" "sonar" "sonar" ;; PRANALYSIS) if [ -n "$SONAR_GITHUB_OAUTH" ] && [ "${TRAVIS_PULL_REQUEST}" != "false" ] then echo "Start pullrequest analysis" mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar -B -e -V -Dmaven.test.failure.ignore=true -Dclirr=true \ -Dsonar.analysis.mode=incremental \ -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \ -Dsonar.github.repository=$SONAR_GITHUB_REPOSITORY \ -Dsonar.github.login=$SONAR_GITHUB_LOGIN \ -Dsonar.github.oauth=$SONAR_GITHUB_OAUTH \ -Dsonar.host.url=$SONAR_HOST_URL \ -Dsonar.login=$SONAR_LOGIN \ -Dsonar.password=$SONAR_PASSWD fi ;; *) echo "Invalid JOB choice [$JOB]" exit 1 esac