Sonar版本:5.3
背景:CTO规划以后要采用Sonar来自动识别程序员代码中的低级错误。采用Jeknis+Sonar集合的方式。
解决方案大致描述:
1)Sonar数据库采用MySQL,目前搭建在db测试服务器90上。
2)Sonar搭建在测试服务器192.168.1.150上。
步骤:
step1:
将如下配置放置到maven.settings文件中,如果嫌格式不清晰,也可以直接参考附件中的settings.xml。
<!-- 插件配置-->
<pluginGroups>
<!-- sonar 设置 -->
<pluginGroup>org.sonarsource.scanner.maven
</pluginGroup>
</pluginGroups>
<!-- profile配置 -->
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>jdbc:mysql://192.168.1.90:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url> <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
<sonar.jdbc.username>nonobank</sonar.jdbc.username>
<sonar.jdbc.password>nonobank!@#</sonar.jdbc.password>
<sonar.host.url>http://192.168.1.150:9000</sonar.host.url>
</properties>
</profile>
</profiles>
step2:
jenkins中配置maven命令如下:
1)clean verify sonar:sonar
2) clean install
3) sonar:sonar
以上,配置完成。