diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-01-11 16:44:38 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-01-11 17:28:15 +0100 |
commit | 8d6e9a735a3ac5c6a729861e776c687d5639e9c1 (patch) | |
tree | 58d9b6d8401e9a70809162b0eb6d2da39f37d2da /travis.sh | |
parent | 5e187f8dc1099ce63c00b9185b9a8a8d9ce92f92 (diff) | |
download | sonar-scanner-cli-8d6e9a735a3ac5c6a729861e776c687d5639e9c1.tar.gz sonar-scanner-cli-8d6e9a735a3ac5c6a729861e776c687d5639e9c1.zip |
Update ITs and enable Dory analysis
Diffstat (limited to 'travis.sh')
-rwxr-xr-x | travis.sh | 98 |
1 files changed, 66 insertions, 32 deletions
@@ -1,55 +1,89 @@ -#!/bin/bash +#!/bin/bash -v set -euo pipefail function installTravisTools { - mkdir ~/.local + mkdir -p ~/.local curl -sSL https://github.com/SonarSource/travis-utils/tarball/v21 | tar zx --strip-components 1 -C ~/.local source ~/.local/bin/install } -if [ -n "${PR_ANALYSIS:-}" ] && [ "${PR_ANALYSIS}" == true ] -then - if [ "$TRAVIS_PULL_REQUEST" != "false" ] - then - # For security reasons environment variables are not available on the pull requests - # coming from outside repositories - # http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests - if [ -n "$SONAR_GITHUB_OAUTH" ]; then +function strongEcho { + echo "" + echo "================ $1 =================" +} + +case "$TARGET" in - # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7 - export JAVA_HOME=/usr/lib/jvm/java-8-oracle - export PATH=$JAVA_HOME/bin:$PATH +CI) + if [ "${TRAVIS_BRANCH}" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + strongEcho 'Build and analyze commit in master' + # this commit is master must be built and analyzed (with upload of report) + mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify -Pcoverage-per-test -Dmaven.test.redirectTestOutputToFile=false -B -e -V - # PR analysis - mvn verify sonar:sonar -B -e -V \ - -Dsonar.analysis.mode=issues \ + # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7 + export JAVA_HOME=/usr/lib/jvm/java-8-oracle + export PATH=$JAVA_HOME/bin:$PATH + + export MAVEN_OPTS="-Xmx1G -Xms128m" + mvn sonar:sonar -B -e -V \ + -Dsonar.host.url=$SONAR_HOST_URL \ + -Dsonar.login=$SONAR_TOKEN + + + elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "$GITHUB_TOKEN" ]; then + # For security reasons environment variables are not available on the pull requests + # coming from outside repositories + # http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests + # That's why the analysis does not need to be executed if the variable SONAR_GITHUB_OAUTH is not defined. + + strongEcho 'Build and analyze pull request' + # this pull request must be built and analyzed (without upload of report) + mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify -Pcoverage-per-test -Dmaven.test.redirectTestOutputToFile=false -B -e -V + + # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7 + export JAVA_HOME=/usr/lib/jvm/java-8-oracle + export PATH=$JAVA_HOME/bin:$PATH + + mvn sonar:sonar -B -e -V \ + -Dsonar.analysis.mode=issues \ -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \ -Dsonar.github.repository=$TRAVIS_REPO_SLUG \ - -Dsonar.github.login=$SONAR_GITHUB_LOGIN \ - -Dsonar.github.oauth=$SONAR_GITHUB_OAUTH \ + -Dsonar.github.oauth=$GITHUB_TOKEN \ -Dsonar.host.url=$SONAR_HOST_URL \ - -Dsonar.login=$SONAR_LOGIN \ - -Dsonar.password=$SONAR_PASSWD - fi - fi -else - # Regular CI (use install for ITs) - mvn install -B -e -V -fi + -Dsonar.login=$SONAR_TOKEN -if [ -n "${RUN_ITS:-}" ] && [ "${RUN_ITS}" == true ] -then - installTravisTools - build_snapshot "SonarSource/orchestrator" + else + strongEcho 'Build, no analysis' + # Build branch, without any analysis + # No need for Maven goal "install" as the generated JAR file does not need to be installed + # in Maven local repository + mvn verify -Dmaven.test.redirectTestOutputToFile=false -B -e -V + fi + ;; + +IT) + installTravisTools if [ "${SQ_VERSION}" == "DEV" ] then build_snapshot "SonarSource/sonarqube" fi + # Need install because ITs will take artifact from local repo + mvn install -B -e -V -Dsource.skip=true -Denforcer.skip=true -Danimal.sniffer.skip=true -Dmaven.test.skip=true + cd it - mvn -DsonarRunner.version="2.5-SNAPSHOT" -Dsonar.runtimeVersion=$SQ_VERSION -Dmaven.test.redirectTestOutputToFile=false install + + build_snapshot "SonarSource/orchestrator" + + mvn -Dsonar.runtimeVersion="$SQ_VERSION" -Dmaven.test.redirectTestOutputToFile=false verify + ;; + +*) + echo "Unexpected TARGET value: $TARGET" + exit 1 + ;; -fi +esac |