-
Notifications
You must be signed in to change notification settings - Fork 1
/
travis.sh
executable file
·107 lines (82 loc) · 3.13 KB
/
travis.sh
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
set -euo pipefail
function installPhantomJs {
echo "Setup PhantomJS 2.1"
mkdir -p ~/phantomjs
pushd ~/phantomjs > /dev/null
if [ ! -d "phantomjs-2.1.1-linux-x86_64" ]; then
wget https://repox.sonarsource.com/public-3rd-parties/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O phantomjs-2.1.1-linux-x86_64.tar.bz2
tar -xf phantomjs-2.1.1-linux-x86_64.tar.bz2
rm phantomjs-2.1.1-linux-x86_64.tar.bz2
fi
popd > /dev/null
export PHANTOMJS_HOME=~/phantomjs/phantomjs-2.1.1-linux-x86_64
export PATH=$PHANTOMJS_HOME/bin:$PATH
}
function configureTravis {
mkdir ~/.local
curl -sSL https://github.com/SonarSource/travis-utils/tarball/v33 | tar zx --strip-components 1 -C ~/.local
source ~/.local/bin/install
}
configureTravis
. installJDK8
./clock.sh &
case "$TARGET" in
CI)
export MAVEN_OPTS="-Xmx1G -Xms128m"
MAVEN_OPTIONS="-Dmaven.test.redirectTestOutputToFile=false -Dsurefire.useFile=false -B -e -V"
INITIAL_VERSION=`maven_expression "project.version"`
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo 'Trigger QA of master branch'
# Fetch all commit history so that SonarQube has exact blame information
# for issue auto-assignment
# This command can fail with "fatal: --unshallow on a complete repository does not make sense"
# if there are not enough commits in the Git repository (even if Travis executed git clone --depth 50).
# For this reason errors are ignored with "|| true"
git fetch --unshallow || true
. set_maven_build_version $TRAVIS_BUILD_NUMBER
mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \
$MAVEN_OPTIONS \
-Pdeploy-sonarsource,stats
elif [[ "$TRAVIS_BRANCH" == "branch-"* ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo 'release branch: trigger QA, no analysis'
. set_maven_build_version $TRAVIS_BUILD_NUMBER
mvn deploy \
$MAVEN_OPTIONS \
-Pdeploy-sonarsource,release,stats
elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
echo 'Internal pull request: trigger QA and analysis'
. set_maven_build_version $TRAVIS_BUILD_NUMBER
mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy sonar:sonar \
$MAVEN_OPTIONS \
-Dsource.skip=true \
-Pdeploy-sonarsource,stats \
-Dsonar.analysis.mode=preview \
-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
echo 'Feature branch or external pull request: no QA, no analysis. Skip sources'
mvn install \
$MAVEN_OPTIONS \
-Dsource.skip=true
fi
installPhantomJs
./run-integration-tests.sh "Lite" "" -Dorchestrator.browser=phantomjs
;;
WEB)
set +u
source ~/.nvm/nvm.sh && nvm install 6
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH=$HOME/.yarn/bin:$PATH
cd server/sonar-web && yarn && yarn test -- --runInBand
;;
*)
echo "Unexpected TARGET value: $TARGET"
exit 1
;;
esac
#stop the clock
touch stop