forked from apereo/cas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze-sonarqube.sh
executable file
·75 lines (59 loc) · 2.29 KB
/
analyze-sonarqube.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
#!/bin/bash
source ./ci/functions.sh
runBuild=false
echo "Reviewing changes that might affect the Gradle build..."
currentChangeSetAffectsStyle
retval=$?
if [ "$retval" == 0 ]
then
echo "Found changes that require the build to run Sonarqube."
runBuild=true
else
echo "Changes do NOT affect project static analysis via Sonarqube."
runBuild=false
fi
if [ "$runBuild" = false ]; then
exit 0
fi
gradle="./gradlew $@"
gradleBuild=""
gradleBuildOptions="--build-cache --configure-on-demand --no-daemon --parallel "
echo -e "***********************************************"
echo -e "Gradle build started at `date`"
echo -e "***********************************************"
gradleBuild="$gradleBuild sonarqube -x javadoc -Dsonar.organization=apereo \
-Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONARCLOUD_TOKEN} \
-DskipGradleLint=true -DskipNestedConfigMetadataGen=true \
--parallel "
if [[ "${TRAVIS_COMMIT_MESSAGE}" == *"[show streams]"* ]]; then
gradleBuild="$gradleBuild -DshowStandardStreams=true "
fi
if [[ "${TRAVIS_COMMIT_MESSAGE}" == *"[rerun tasks]"* ]]; then
gradleBuild="$gradleBuild --rerun-tasks "
fi
if [[ "${TRAVIS_COMMIT_MESSAGE}" == *"[refresh dependencies]"* ]]; then
gradleBuild="$gradleBuild --refresh-dependencies "
fi
if [ -z "$gradleBuild" ]; then
echo "Gradle build will be ignored since no commands are specified to run."
else
tasks="$gradle $gradleBuildOptions $gradleBuild"
echo -e "***************************************************************************************"
echo $tasks
echo -e "***************************************************************************************"
waitloop="while sleep 9m; do echo -e '\n=====[ Gradle build is still running ]====='; done &"
eval $waitloop
waitRetVal=$?
eval $tasks
retVal=$?
echo -e "***************************************************************************************"
echo -e "Gradle build finished at `date` with exit code $retVal"
echo -e "***************************************************************************************"
if [ $retVal == 0 ]; then
echo "Gradle build finished successfully."
exit 0
else
echo "Gradle build did NOT finish successfully."
exit $retVal
fi
fi