參考:
jenkins集成sonarQube分析maven項目
jenkins集成sonar,maven,git進行代碼分析
- 配置pom.xml
其實參考文章里都是配置setting.xml,但是我偷懶直接在pom.xml里配置了。
<!在<profiles>節(jié)點中添加:>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.host.url>
http://sonarQube所在的服務器IP地址:9000
</sonar.host.url>
</properties>
</profile>
-
在Sonar Queb中生成token
<1>.登錄sonarQube
<2>.配置–權限,點擊下圖所標注的位置:
生成token
<3>.在彈出窗口中填寫名稱,生成后必須立即復制,因為token只會顯示一次。
生成的token必須立即保存 -
Jenkins中集成Sonar Qube
<1>.在jenkins中安裝SonarQube Scanner for Jenkins插件
安裝SonarQube Scanner for Jenkins插件
<2>.在配置頁對SonarQube servers進行配置:
系統(tǒng)配置–系統(tǒng)設置–SonarQube servers/Quality Gates - Sonarqube
配置.png
<3>.在待分析的項目配置中填寫分析命令
分析命令
現(xiàn)在就可以進行構建了。




