SonarQube下載https://www.sonarqube.org/downloads/
一.安裝SonarQube
將來下載的SonarQube解壓打開bin目錄,啟動相應OS目錄下的StartSonar。使用的是win的32位系統(tǒng),則打開D:\sonarqube-5.6.6\sonarqube-5.6.6\bin\windows-x86-32\StartSonar.bat
啟動瀏覽器訪問 http://localhost:9000 出現(xiàn)sonarqube界面則說明安轉(zhuǎn)成功
二、配置
1、1.打開mysql,新建一個數(shù)據(jù)庫。
2、打開sonarqube安裝目錄下的D:\sonarqube-5.6.6\sonarqube-5.6.6\conf\sonar.properties文件
再mysql5.6 下添加
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=root
sonar.jdbc.password=***
sonar.sorceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
4.重啟sonarqube服務,再次訪問http://localhost:9000,會稍微有點慢,因為要初始化數(shù)據(jù)庫信息
5.數(shù)據(jù)庫初始化成功后,登錄
6.進入插件安裝頁面
7、chinese pack 安裝成功后重啟服務。
三、Connected Mode
1、file->setting->other setting 配置sonarqube servers
2、test connect error
3、更新sonarjava跟sonarjs
4、新建項目
正在上傳...取消
5、綁定idea項目至sonaerqube 項目
6、執(zhí)行。
執(zhí)行后在idea的控制臺可以看到sonar lint 的結(jié)果。但是在服務器上無法看到結(jié)果???
四、通過maven來執(zhí)行
1、配置maven
pom.xml
<plugin>
? ? ? ? <groupId>org.sonarsource.scanner.maven</groupId>
? ? ? ? <artifactId>sonar-maven-plugin</artifactId>
? ? ? ? <version>3.2</version>
? ? ? </plugin>
? ? ? <plugin>
setting.xml
<profiles>
? ? ? <profile>
? ? ? ? ? <id>sonar</id>
? ? ? ? ? <activation>
? ? ? ? ? ? ? <activeByDefault>true</activeByDefault>
? ? ? ? ? </activation>
? ? ? ? ? <properties>
? ? ? ? ? ? ? <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar</sonar.jdbc.url>
? ? ? ? ? ? ? <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
? ? ? ? ? ? ? <sonar.jdbc.username>root</sonar.jdbc.username>
? ? ? ? ? ? ? <sonar.jdbc.password>jkzl123456</sonar.jdbc.password>
? ? ? ? ? ? ? <sonar.host.url>http://localhost:9000</sonar.host.url>
? ? ? ? ? </properties>
? ? ? </profile>
</profiles>
?<pluginGroups>
? ? ? ? <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
? ? </pluginGroups>
2、控制臺執(zhí)行mvn clean install ,mvn sonar:sonar
3、打開localhost:9000