Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #4912: add initial scripts for running sonar in docker #4949

Merged
merged 1 commit into from Aug 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions .ci/sonar-wrapper.sh
@@ -0,0 +1,18 @@
#!/bin/sh

#This file is for manual execution only

set -e

echo "Building docker image"
docker pull sonarqube
echo "Running docker container"
docker run -dit -p 9000:9000 --name sonar sonarqube:latest
echo "sleeping 60 sec to let sonar start up"
sleep "60"

./.ci/sonar.sh

#kill container
docker stop sonar
docker rm sonar
26 changes: 26 additions & 0 deletions .ci/sonar.sh
@@ -0,0 +1,26 @@
#!/bin/sh

#set checkstyle sonar profile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make this file as shell file (not a source) to allow multiple execution on running Sonar instance.
please make file executable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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