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