Skip to content

Commit be59b3a

Browse files
committed
store sonarqube credentials in seperate file
1 parent bf0cfdd commit be59b3a

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

scripts/SonarQubeCredentials.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/runSonarQube.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
#!/usr/bin/env bash
22

3+
source scripts/requireCommand.sh
4+
5+
requireCommand curl
6+
requireCommand jq
7+
38
# Check for install/updates at https://github.com/SonarSource/sonarqube
49

5-
sonar_host="http://localhost:9000"
6-
sonar_project="benchmark"
7-
sonar_token="291e50b66b5f5198e6ac0d49bf1057ac3a3a0fc8"
10+
if [ ! -f scripts/SonarQubeCredentials.sh ]; then
11+
cat > scripts/SonarQubeCredentials.sh << EOF
12+
#!/usr/bin/env bash
13+
14+
sonar_host="" # e. g. http://localhost:9000
15+
sonar_project=""
16+
sonar_token=""
17+
EOF
18+
chmod +x scripts/SonarQubeCredentials.sh
19+
fi
20+
21+
source scripts/SonarQubeCredentials.sh
22+
23+
if [ -z "$sonar_host" ] || [ -z "$sonar_project" ] || [ -z "$sonar_token" ]; then
24+
echo "Please provide credentials in SonarQubeCredentials.sh"
25+
exit 1
26+
fi
827

9-
mvn sonar:sonar \
10-
-Dsonar.projectKey="$sonar_project" \
11-
-Dsonar.host.url="$sonar_host" \
12-
-Dsonar.login="$sonar_token"
28+
mvn sonar:sonar -Dsonar.projectKey="$sonar_project" -Dsonar.host.url="$sonar_host" -Dsonar.login="$sonar_token"
1329

1430
sleep 300s # might be replaced with polling of $sonar_host/api/ce/component?component=$sonar_project
1531

0 commit comments

Comments
 (0)