-
Notifications
You must be signed in to change notification settings - Fork 70
How to build and test plugin on local
Requirements: 64 bit OS. 32 bit will end instantly with no error to be found.
- Launch Sonar in Docker
if already run sonar in docker:
docker start sonarqube
(you can recheck it by docker images
)
if no sonarqube container(USE THIS):
Run: docker run -d --name sonarqube-7.7-community -p 9000:9000 -p 9092:9092 sonarqube-7.7-community
Latest (just in case): docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0258089f3c31 sonarqube "./bin/run.sh" 3 minutes ago Up 3 minutes 0.0.0.0:9000->9000/tcp, 0.0.0.0:9092->9092/tcp sonarqub
1.1) Log into http://localhost:9000/admin/marketplace?search=checkstyle (admin/admin) and install checkstyle . Do restart.
1.2) After restart create new profile , make is default, activate all checks that are changed in new checkstyle release.
1.3) do validation of code by mvn sonar:sonar
.
It is better to have some violations from activated rules.
- build upgraded to new checkstyle plugin and copy resulted file to docker container
mvn clean package
docker exec sonarqube-7.7-community rm /opt/sonarqube/extensions/plugins/$(docker exec sonarqube-7.7-community ls /opt/sonarqube/extensions/plugins/ | grep checkstyle)
docker cp $(find . -name *SNAPSHOT.jar) sonarqube-7.7-community:/opt/sonarqube/extensions/plugins
- restart docker
docker stop sonarqube-7.7-community && sleep 5 && docker start sonarqube-7.7-community
- recheck New Rules at http://localhost:9000/coding_rules#languages=java|repositories=checkstyle , activate Rules. Login: admin/admin
In case problems, login by ssh: docker exec -i -t sonarqube-7.7-community /bin/bash
4.1) Activate some Checkstyle rules (all of them are not active by default)
- try to run on some sources
mvn sonar:sonar
- Recheck results at http://localhost:9000/dashboard/index/1
useful command for repetitive executions:
mvn clean package && docker cp $(find . -name *SNAPSHOT.jar) sonarqube-7.7-community:/opt/sonarqube/extensions/plugins && docker stop sonarqube-7.7-community && sleep 5 && docker start sonarqube-7.7-community
get logs from not running contianer:
docker cp sonarqube-7.7-community:/opt/sonarqube/logs/sonar.log /tmp && less /tmp/sonar.log
docker cp sonarqube-7.7-community:/opt/sonarqube/logs/web.log /tmp && less /tmp/web.log
view docker log:
journalctl -u docker.service