-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtravis.sh
More file actions
executable file
·72 lines (60 loc) · 2.44 KB
/
travis.sh
File metadata and controls
executable file
·72 lines (60 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -euo pipefail
function configureTravis {
mkdir ~/.local
curl -sSL https://github.com/SonarSource/travis-utils/tarball/v25 | tar zx --strip-components 1 -C ~/.local
source ~/.local/bin/install
}
function strongEcho {
echo ""
echo "================ $1 ================="
}
configureTravis
case "$TEST" in
CI)
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
strongEcho "Build and analyze commit in master"
SONAR_PROJECT_VERSION=`maven_expression "project.version"`
# Do not deploy a SNAPSHOT version but the release version related to this build
set_maven_build_version $TRAVIS_BUILD_NUMBER
# integration of jacoco report is quite memory-consuming
export MAVEN_OPTS="-Xmx1536m -Xms128m"
git fetch --unshallow
mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar -B -e -V \
-Pcoverage-per-test \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.projectVersion=$SONAR_PROJECT_VERSION \
-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 GITHUB_TOKEN is not defined.
strongEcho "Build and analyze pull request"
export MAVEN_OPTS="-Xmx1G -Xms128m"
mvn verify sonar:sonar -B -e -V \
-Dsonar.analysis.mode=issues \
-Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \
-Dsonar.github.repository=$TRAVIS_REPO_SLUG \
-Dsonar.github.oauth=$GITHUB_TOKEN \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_TOKEN
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 -B -e -V
fi
;;
plugin|ruling)
[ "$TEST" = "ruling" ] && git submodule update --init --recursive
EXTRA_PARAMS=
[ -n "${PROJECT:-}" ] && EXTRA_PARAMS="-DfailIfNoTests=false -Dtest=JavaRulingTest#$PROJECT"
mvn package -Dsonar.runtimeVersion="$SQ_VERSION" -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Pit-$TEST $EXTRA_PARAMS
;;
*)
echo "Unexpected TEST mode: $TEST"
exit 1
;;
esac