You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

travis.sh 4.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash -v
  2. set -euo pipefail
  3. function installTravisTools {
  4. mkdir -p ~/.local
  5. curl -sSL https://github.com/SonarSource/travis-utils/tarball/v21 | tar zx --strip-components 1 -C ~/.local
  6. source ~/.local/bin/install
  7. }
  8. function strongEcho {
  9. echo ""
  10. echo "================ $1 ================="
  11. }
  12. case "$TARGET" in
  13. CI)
  14. if [ "${TRAVIS_BRANCH}" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
  15. strongEcho 'Build and analyze commit in master'
  16. # this commit is master must be built and analyzed (with upload of report)
  17. mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify -Pcoverage-per-test -Dmaven.test.redirectTestOutputToFile=false -B -e -V
  18. # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7
  19. export JAVA_HOME=/usr/lib/jvm/java-8-oracle
  20. export PATH=$JAVA_HOME/bin:$PATH
  21. export MAVEN_OPTS="-Xmx1G -Xms128m"
  22. mvn sonar:sonar -B -e -V \
  23. -Dsonar.host.url=$SONAR_HOST_URL \
  24. -Dsonar.login=$SONAR_TOKEN
  25. elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "$GITHUB_TOKEN" ]; then
  26. # For security reasons environment variables are not available on the pull requests
  27. # coming from outside repositories
  28. # http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests
  29. # That's why the analysis does not need to be executed if the variable SONAR_GITHUB_OAUTH is not defined.
  30. strongEcho 'Build and analyze pull request'
  31. # this pull request must be built and analyzed (without upload of report)
  32. mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify -Pcoverage-per-test -Dmaven.test.redirectTestOutputToFile=false -B -e -V
  33. # Switch to java 8 as the Dory HTTPS certificate is not supported by Java 7
  34. export JAVA_HOME=/usr/lib/jvm/java-8-oracle
  35. export PATH=$JAVA_HOME/bin:$PATH
  36. mvn sonar:sonar -B -e -V \
  37. -Dsonar.analysis.mode=issues \
  38. -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \
  39. -Dsonar.github.repository=$TRAVIS_REPO_SLUG \
  40. -Dsonar.github.oauth=$GITHUB_TOKEN \
  41. -Dsonar.host.url=$SONAR_HOST_URL \
  42. -Dsonar.login=$SONAR_TOKEN
  43. else
  44. strongEcho 'Build, no analysis'
  45. # Build branch, without any analysis
  46. # No need for Maven goal "install" as the generated JAR file does not need to be installed
  47. # in Maven local repository
  48. mvn verify -Dmaven.test.redirectTestOutputToFile=false -B -e -V
  49. fi
  50. ;;
  51. IT)
  52. installTravisTools
  53. if [ "${SQ_VERSION}" == "DEV" ]
  54. then
  55. build_snapshot "SonarSource/sonarqube"
  56. fi
  57. # Need install because ITs will take artifact from local repo
  58. mvn install -B -e -V -Dsource.skip=true -Denforcer.skip=true -Danimal.sniffer.skip=true -Dmaven.test.skip=true
  59. cd it
  60. build_snapshot "SonarSource/orchestrator"
  61. mvn -Dsonar.runtimeVersion="$SQ_VERSION" -Dmaven.test.redirectTestOutputToFile=false verify
  62. ;;
  63. *)
  64. echo "Unexpected TARGET value: $TARGET"
  65. exit 1
  66. ;;
  67. esac