Skip to content

Commit 0c4a91a

Browse files
committed
created sonar_scan shell script for local
1 parent c4b627a commit 0c4a91a

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

File renamed without changes.

scripts/run_sonar_scan.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Resolve the project root directory (assuming this script is inside the 'scripts' folder)
4+
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ENV_FILE="$PROJECT_ROOT/.env"
6+
7+
# Check if .env file exists
8+
if [ ! -f "$ENV_FILE" ]; then
9+
echo "Error: .env file not found at $ENV_FILE"
10+
exit 1
11+
fi
12+
13+
# Extract SONAR_TOKEN from .env
14+
# This looks for the key, splits by =, removes quotes (single or double), and removes Windows carriage returns
15+
SONAR_TOKEN=$(grep "^SONAR_TOKEN=" "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | tr -d "'" | tr -d '\r')
16+
17+
if [ -z "$SONAR_TOKEN" ]; then
18+
echo "Error: SONAR_TOKEN not found or empty in .env file."
19+
exit 1
20+
fi
21+
22+
# Navigate to project root and run the Gradle command
23+
cd "$PROJECT_ROOT" || exit
24+
./gradlew clean build jacocoTestReport sonar -Dsonar.token="$SONAR_TOKEN"

0 commit comments

Comments
 (0)