SonarQube 6.4代碼品質管理平台安裝與使用

來源:互聯網
上載者:User

預置條件
  已安裝Java JDK1.8環境
  已安裝有Oracle 11g+資料庫


一、SonarQube 6.4安裝

1.軟體下載地址:http://www.sonarqube.org/downloads/


2.下載sonarqube-6.4.zip並解壓到你的檔案夾裡


3.修改設定檔sonarqube-6.4\conf\sonar.properties

#資料庫配置sonar.jdbc.username=mydevsonar.jdbc.password=mydevsonar.jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:dbdev#IP、連接埠、上下文配置sonar.web.host=127.0.0.1sonar.web.context=/sonarsonar.web.port=8086

4.添加oracle驅動包到sonarqube-6.4\extensions\jdbc-driver\oracle\目錄下,需要oracle 11g+ 版本的驅動 ojdbc6.jar。


5.中文補丁下載:https://github.com/SonarQubeCommunity/sonar-l10n-zh  

下載源碼包後: mvn install 打包成jar,拷貝到sonarqube-6.4\extensions\plugins\




6.進入bin目錄,選擇版本啟動。
本地是windows-x86-64,所以進入檔案夾,選擇StartSonar.bat,雙擊啟動。


啟動成功控制台結果


7.瀏覽器訪問http://127.0.0.1:8086/sonar/ , 登入:admin/admin




二、SonarQube Scanner 3.0.3掃描器安裝

1.下載地址:https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.3.778-windows.zip

2.將下載包解壓,通過編輯sonar-scanner/conf/sonar-scanner.properties,將全域設定更新為指向SonarQube伺服器:

#----- Default SonarQube serversonar.host.url=http://127.0.0.1:8086/sonar

3.將sonar-scanner/bin目錄,添加到系統內容變數的path中。


4.運行cmd輸入命令:sonar-scanner -v 驗證安裝是否正確,正確結果輸出:



三、使用

1.登入sonarQude平台,建立新項目。轉到‘配置>項目>管理’ ,然後單擊‘建立項目’。 唯一必需的資訊是項目的關鍵和名稱。




2.項目代碼配置及運行掃描。

在項目的根目錄中建立一個設定檔:sonar-project.properties


sonar-project.properties配置:

# must be unique in a given SonarQube instancesonar.projectKey=ProjectOneKey# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.sonar.projectName=MyProjectOnesonar.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=src

再項目根目錄cmd運行以下命令啟動分析:
sonar-scanner

掃描分析成功輸出



進入SonarQude管理平台查看分析結果





更多操作詳見官方文檔:https://docs.sonarqube.org/display/HOME/SonarQube+Platform



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.