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 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. set -euo pipefail
  3. function configureTravis {
  4. mkdir ~/.local
  5. curl -sSL https://github.com/SonarSource/travis-utils/tarball/v29 | tar zx --strip-components 1 -C ~/.local
  6. source ~/.local/bin/install
  7. echo "$ARTIFACTORY_URL/npmjs/" > .npmrc
  8. }
  9. configureTravis
  10. . installJDK8
  11. function strongEcho {
  12. echo ""
  13. echo "================ $1 ================="
  14. }
  15. case "$TARGET" in
  16. CI)
  17. if [ "${TRAVIS_BRANCH}" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
  18. strongEcho 'Build and deploy'
  19. # Do not deploy a SNAPSHOT version but the release version related to this build
  20. set_maven_build_version $TRAVIS_BUILD_NUMBER
  21. # analysis is currently executed by SonarSource internal infrastructure
  22. mvn deploy \
  23. -Pdeploy-sonarsource \
  24. -B -e -V
  25. elif [[ "${TRAVIS_BRANCH}" == "branch-"* ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
  26. strongEcho 'Build and deploy'
  27. # get current version from pom
  28. CURRENT_VERSION=`maven_expression "project.version"`
  29. if [[ $CURRENT_VERSION =~ "-SNAPSHOT" ]]; then
  30. echo "======= Found SNAPSHOT version ======="
  31. # Do not deploy a SNAPSHOT version but the release version related to this build
  32. set_maven_build_version $TRAVIS_BUILD_NUMBER
  33. else
  34. echo "======= Found RELEASE version ======="
  35. fi
  36. # analysis is currently executed by SonarSource internal infrastructure
  37. mvn deploy \
  38. -Pdeploy-sonarsource \
  39. -B -e -V
  40. elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
  41. strongEcho 'Build and analyze pull request, no deploy'
  42. # No need for Maven phase "install" as the generated JAR file does not need to be installed
  43. # in Maven local repository. Phase "verify" is enough.
  44. export MAVEN_OPTS="-Xmx1G -Xms128m"
  45. mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar \
  46. -Dsonar.analysis.mode=issues \
  47. -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \
  48. -Dsonar.github.repository=$TRAVIS_REPO_SLUG \
  49. -Dsonar.github.oauth=$GITHUB_TOKEN \
  50. -Dsonar.host.url=$SONAR_HOST_URL \
  51. -Dsonar.login=$SONAR_TOKEN \
  52. -B -e -V
  53. else
  54. strongEcho 'Build, no analysis, no deploy'
  55. # No need for Maven phase "install" as the generated JAR file does not need to be installed
  56. # in Maven local repository. Phase "verify" is enough.
  57. mvn verify \
  58. -Dmaven.test.redirectTestOutputToFile=false \
  59. -B -e -V
  60. fi
  61. ;;
  62. WEB)
  63. set +eu
  64. source ~/.nvm/nvm.sh && nvm install 4
  65. npm install -g npm@3.5.2
  66. cd server/sonar-web && npm install && npm test
  67. ;;
  68. IT)
  69. start_xvfb
  70. mvn install -DskipTests=true -Dsource.skip=true -Denforcer.skip=true -B -e -V
  71. ./run-integration-tests.sh "$IT_CATEGORY" "" -Dmaven.test.redirectTestOutputToFile=false -Dexclude-qa-tests=true
  72. ;;
  73. *)
  74. echo "Unexpected TARGET value: $TARGET"
  75. exit 1
  76. ;;
  77. esac