1. 用docker起sonarqube
(1) docker pull sonarqube
(2) docker run -d --name sonarqube -p 9096:9000 -p 9094:9094 sonarqube
(先不管db 用embedded的)
(3) http://ip:9096/about 用admin/admin可登入 知道起成功了
2. eclipse安裝SonarLint套件
(1) 依步驟設定指向剛建好的server
(2) 專案按右建SonarLint→Analyze就能分析專案了,但結果只會在本機,不會上到server
3. 非maven專案要把scan結果上到server:需另外下載scanner
(https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner)
(1) Expand the downloaded file into the directory of your choice. We'll refer to it as <install_directory> in the next steps.
(2) Update the global settings to point to your SonarQube server by editing <install_directory>/conf/sonar-scanner.properties:
#----- Default SonarQube server
#sonar.host.url=http://localhost:9000
(3) Add the <install_directory>/bin directory to your path.
(4) Create a configuration file in the root directory of the project: sonar-project.properties
sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=My project
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
(5) Run the following command from the project base directory to launch the analysis:
sonar-scanner
(6) 執行成功就能在server 的web ui上看到這個project了
4. maven專案要把scan結果上到server
(1) 在setting裡設定以下
<settings>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
</settings>
(2) 執行maven時 goal寫clean install sonar:sonar 就能在server web ui上看到了
WEB UI的基本講解
https://blog.gss.com.tw/index.php/2017/04/21/sonarqube2/
沒有留言:
張貼留言