forked from SoPra-Team-10/Network
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-sonarqube.sh
46 lines (32 loc) · 1.21 KB
/
run-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
#!/bin/bash
echo "Current Branch: $TRAVIS_BRANCH"
if [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "develop" ] || [ "$TRAVIS_BRANCH" == "sonarcloud" ]; then
echo "INSTALLING SOME TOOLS"
apt-get install -y wget unzip bash
echo "INSTALLING SONAR CUBE SANNER & WRAPPER"
mkdir /sonar
cd /sonar
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip sonar-scanner-cli-4.2.0.1873-linux.zip
unzip build-wrapper-linux-x86.zip
cd sonar-scanner-4.2.0.1873-linux/bin
chmod +x sonar-scanner
cd ../..
cd build-wrapper-linux-x86
chmod +x build-wrapper-linux-x86-64
cd ..
cd /src
echo "RUNNING SONARCLOUD BUILD WRAPPER"
chmod +x sonar-build.sh
/sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-outputs ./sonar-build.sh
echo "RUNNING SONARCLOUD SCANNER"
/sonar/sonar-scanner-4.2.0.1873-linux/bin/sonar-scanner \
-Dsonar.login=$SONAR_TOKEN -Dsonar.branch.name=$TRAVIS_BRANCH \
-X
rm -rf sonar-build
rm -rf ./bw-outputs
else
echo "No Code Analysis for $TRAVIS_BRANCH Branch."
exit 0
fi