From 84a628277d4aa46b6ada2188559d98e3a2115614 Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Wed, 16 Sep 2026 11:16:10 +0100 Subject: [PATCH] new deployer command --- .gitignore | 1 + sonar-export.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100755 sonar-export.sh diff --git a/.gitignore b/.gitignore index 89e18465..85b688fb 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ composer.lock /storage/framework/ /storage/debugbar/ /phpunit.dusk.xml +/sonarqube-issues.csv diff --git a/sonar-export.sh b/sonar-export.sh new file mode 100755 index 00000000..32192858 --- /dev/null +++ b/sonar-export.sh @@ -0,0 +1,77 @@ +#!/bin/bash +set -euo pipefail + +SONAR_URL="http://192.168.1.2:9001" +PROJECT="Warehouse-Management-System" +OUTPUT="sonarqube-issues.csv" +TMP=$(mktemp) + +if [ -z "${SONAR_TOKEN:-}" ]; then + echo "SONAR_TOKEN is not set" + exit 1 +fi + +echo "Downloading SonarQube issues for $PROJECT..." + +echo '[]' > "$TMP" + +PAGE=1 +PAGE_SIZE=500 + +while true; do + echo "Fetching page $PAGE..." + + RESPONSE=$(curl --connect-timeout 5 --max-time 60 -sS \ + -u "$SONAR_TOKEN:" \ + "$SONAR_URL/api/issues/search?componentKeys=$PROJECT&ps=$PAGE_SIZE&p=$PAGE") + + COUNT=$(echo "$RESPONSE" | jq '.issues | length') + TOTAL=$(echo "$RESPONSE" | jq '.total') + + echo " $COUNT issues received ($TOTAL total)" + + jq -s '.[0] + .[1].issues' "$TMP" <(echo "$RESPONSE") > "$TMP.new" + mv "$TMP.new" "$TMP" + + [ "$COUNT" -lt "$PAGE_SIZE" ] && break + + PAGE=$((PAGE + 1)) +done + +jq -r ' +[ + "Severity", + "Type", + "Status", + "Rule", + "File", + "Line", + "Message", + "Effort", + "Assignee", + "Author", + "Created", + "Updated" +], +(.[] | [ + .severity, + .type, + .status, + .rule, + (.component | sub("^Warehouse-Management-System:";"")), + (.line // ""), + .message, + (.effort // ""), + (.assignee // ""), + (.author // ""), + .creationDate, + .updateDate +]) | @csv +' "$TMP" > "$OUTPUT" + +rm "$TMP" + +echo +echo "Complete." +echo "Report: $OUTPUT" +echo "Issues exported: $(($(wc -l < "$OUTPUT") - 1))"