-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-all.sh
More file actions
executable file
·45 lines (36 loc) · 1.16 KB
/
build-all.sh
File metadata and controls
executable file
·45 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
shopt -s extglob
timed() {
end=$(date +%s)
dt=$(($end - $1))
dd=$(($dt / 86400))
dt2=$(($dt - 86400 * $dd))
dh=$(($dt2 / 3600))
dt3=$(($dt2 - 3600 * $dh))
dm=$(($dt3 / 60))
ds=$(($dt3 - 60 * $dm))
LC_NUMERIC=C printf "\nTotal runtime: %02d min %02d seconds\n" "$dm" "$ds"
}
start=$(date +%s)
trap 'timed $start' EXIT
token="$1"
if [[ -z "$token" ]]; then
echo "Usage: $(basename "$0") <token>"
exit 1
fi
shift
coverage_file="$(cd "$(dirname "$0")" && pwd)/coverage.txt"
: > "$coverage_file"
for dir in ./modules/*; do
name="$(basename "$dir")"
printf "\n=== Building project '%s' ===\n" "$(basename "$dir")"
sonar_plugin="$(cd "$(dirname "$0")" && pwd)/sonar.gradle"
"$dir"/gradlew clean build jacocoTestReport sonar -p "$dir" --init-script "$sonar_plugin" -Ptoken="$token"
response=$(curl -fsS -u "$token:" "http://localhost:9000/api/measures/component?component=$name&metricKeys=coverage" || true)
if [[ -z "$response" ]]; then
coverage="0"
else
coverage="$(printf "%s" "$response" | jq -r '.component.measures[0].value' 2>/dev/null || echo "0")"
fi
printf "%s\t%s\n" "$name" "$coverage" >> "$coverage_file"
done