aboutsummaryrefslogtreecommitdiff
path: root/.ci/sonar.sh
blob: 9172697e4d562eb79116f49f26ac17bd5dfeec38 (plain)
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
#!/bin/sh

#set checkstyle sonar profile
curl -X POST -u admin:admin -F 'backup=@config/default_sonar_profile.xml' -v http://localhost:9000/api/profiles/restore

#execute inspection
mvn sonar:sonar -P sonar -Dsonar.language=java -Dsonar.profile=checksyle-profile

# Uncomment following to get HTML report.
# mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.issuesReport.html.enable=true \
#        -Dsonar.language=java -Dsonar.profile=checksyle-profile


#get and parse response from sonar
#give some time to sonar for report processing
sleep "60"
curl -u admin:admin -v http://localhost:9000/api/issues/search?componentRoots=com.puppycrawl.tools:checkstyle \
        > response.json

OUTPUT="$(cat response.json | jq '.total')"

#print number of found issues
if [ ! "$OUTPUT" -eq "0" ]; then
    jq '.' response.json
    echo "Found issues - $OUTPUT"
fi