aboutsummaryrefslogtreecommitdiff
path: root/nvim/scripts/sonarqube.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/scripts/sonarqube.sh')
-rwxr-xr-xnvim/scripts/sonarqube.sh27
1 files changed, 19 insertions, 8 deletions
diff --git a/nvim/scripts/sonarqube.sh b/nvim/scripts/sonarqube.sh
index 15c042e..ee2148e 100755
--- a/nvim/scripts/sonarqube.sh
+++ b/nvim/scripts/sonarqube.sh
@@ -2,17 +2,28 @@
2 2
3set -eu 3set -eu
4 4
5errexit() {
6 echo "$@" >&2
7 exit "${2:-1}"
8}
9
10command -v curl >/dev/null || errexit "curl nicht installiert"
11command -v jq >/dev/null || errexit "jq nicht installiert"
12
5SONAR_CONFIGURATION_FILE="/opt/homebrew/etc/sonar-scanner.properties" 13SONAR_CONFIGURATION_FILE="/opt/homebrew/etc/sonar-scanner.properties"
6PROJECT_FILE=$(find . -maxdepth 1 -name "sonar-project*.properties" | head -n 1) 14[ -f "$SONAR_CONFIGURATION_FILE" ] || errexit "Keine globale sonarcube Konfiguration gefunden!"
15
16PROJECT_FILE=$(find . -maxdepth 1 -name "sonar-project*.properties" -print -quit)
17[ -n "$PROJECT_FILE" ] || errexit "Keine sonar-project*.properties Datei gefunden!"
18
19SONAR_TOKEN=$(awk -F= '/^sonar.token=/ {gsub(/^[ \t]+|[ \t]+$/,"",$2); print $2}' "$SONAR_CONFIGURATION_FILE")
20[ -n "$SONAR_TOKEN" ] || errexit "Kein 'sonar.token' in $SONAR_CONFIGURATION_FILE vorhanden"
7 21
8if [ -z "$PROJECT_FILE" ]; then 22SONAR_HOST_URL=$(awk -F= '/^sonar.host.url=/ {gsub(/^[ \t]+|[ \t]+$/,"",$2); print $2}' "$SONAR_CONFIGURATION_FILE")
9 echo "Keine sonar-project*.properties Datei gefunden!" >&2 23[ -n "$SONAR_HOST_URL" ] || errexit "Kein 'sonar.host.url' in $SONAR_CONFIGURATION_FILE vorhanden"
10 exit 1
11fi
12 24
13SONAR_TOKEN=$(awk -F= '/^sonar.token=/ {print $2}' "$SONAR_CONFIGURATION_FILE") 25PROJECT_KEY=$(awk -F= '/^sonar.projectKey=/ {gsub(/^[ \t]+|[ \t]+$/,"",$2); print $2}' "$PROJECT_FILE")
14SONAR_HOST_URL=$(awk -F= '/^sonar.host.url=/ {print $2}' "$SONAR_CONFIGURATION_FILE") 26[ -n "$PROJECT_KEY" ] || errexit "Kein 'sonar.projectKey' in $PROJECT_FILE vorhanden"
15PROJECT_KEY=$(awk -F= '/^sonar.projectKey=/ {print $2}' "$PROJECT_FILE")
16 27
17curl -s \ 28curl -s \
18 -u "$SONAR_TOKEN:" \ 29 -u "$SONAR_TOKEN:" \