forked from SonarSource/sonar-training-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlib.sh
executable file
·33 lines (28 loc) · 980 Bytes
/
sqlib.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
#!/bin/bash
# This file to be source'd by other shells makes sure that a common environment is used for all
# SonarQube API calls and scanner execution
if [ "$SONAR_TOKEN" = "" ]; then
if [ "$TOKEN" != "" ]; then
export SONAR_TOKEN=$TOKEN
fi
fi
if [ "$SONAR_TOKEN" = "" ]; then
printf "SonarQube token not set. Enter token: "
read token
export SONAR_TOKEN=$token
fi
if [ "$SONAR_HOST_URL" = "" ]; then
if [ "$URL" != "" ]; then
export SONAR_HOST_URL=$URL
fi
fi
if [ "$SONAR_HOST_URL" = "" ]; then
printf "SonarQube URL not set. Enter URL: "
read url
export SONAR_HOST_URL=$url
fi
# Strip possible past login and URL from SCANNER_OPTS
opts=`echo $SONAR_SCANNER_OPTS | sed -e 's/-Dsonar.host.url=[^ ]*//g' -e 's/-Dsonar.login=[^ ]*//g' -e 's/-Dsonar.password=\S*//g'`
# Set new login and URL
export SONAR_SCANNER_OPTS="$opts -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_TOKEN"
printf "\n\nRunning against $SONAR_HOST_URL\n\n"