wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
unzip sonar-scanner-cli-4.7.0.2747-linux.zip -d /opt
2. 將sonar-scanner加入PATH路徑
vi /etc/profile
export SONAR_SCANNER_HOME=/opt/sonar-scanner-4.7.0.2747-linux
export PATH=$PATH:$SONAR_SCANNER_HOME/bin
source /etc/profile
3. 測試
sonar-scanner -v
4. 下載一個spring boot的範例程式碼,並且利用maven進行編譯
git clone https://gitlab.abow.online/abowspy/spring-boot-demo.git
cd spring-boot-demo/
mvn clean package
6. 進行程式碼掃描
sonar-scanner \
-Dsonar.host.url=http://192.168.1.124:9000 \
-Dsonar.projectKey=spring-boot-demo \
-Dsonar.projectName=spring-boot-demo \
-Dsonar.projectVersion=1.0 \
-Dsonar.login=admin \
-Dsonar.password=1q2w3e4r \
-Dsonar.ws.timeout=30 \
-Dsonar.projectDescription="my first project" \
-Dsonar.links.homepage=http://www.google.com \
-Dsonar.sources=src \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.java.binaries=target/classes \
-Dsonar.java.test.binaries=target/test-classes \
-Dsonar.java.surefire.report=target/surefire-reports
7. 最後成功的話,網頁就會看見如下: