搭建Sonarqube

本文的sonarqube搭建在 SuSE Linux上进行.

1 安装 装 e SonarQube 的 的  Web Server
下载最新 LTS 版的 SonarQube 安装包(当前版本为 sonarqube-4.5.4.zip) :
下载地址:http://www.sonarqube.org/downloads/

这里写图片描述

2.下载:
# wget http://dist.sonar.codehaus.org/sonarqube-4.5.4.zip
解压安装:
# unzip sonarqube-4.5.4.zip
# mv sonarqube-4.5.4 sonarqube

编辑 sonar 配置:
# cd sonarqube/conf/
# vi sonar.properties

sonar.web.host=192.168.1.132
sonar.web.context=/sonarqube
sonar.web.port=9000


3.在防火墙开启9000端口的访问
cd /etc/sysconfig/
vi SuSEfirewall2

这里写图片描述

重启防火墙使配置生效
# rcSuSEfirewall2 restart

启运SonarQube Web Server
bogon:/home/javadev/sonarqube/bin/linux-x86-64 # ./sonar.sh start

在浏览器中访问地址: http://192.168.1.132:9000/sonarqube/

这里写图片描述

登录,默认用户名/密码为 admin/admin

到此 SonarQube  已 安装完毕 , 接下来是对SonarQube  做相应的配置和使用


4、 Maven 分析器插件的配置与使用

  <profiles>
        <profile>
            <id>edu</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.7</jdk>
            </activation>
            <repositories>
                <!-- 私有库地址-->
                <repository>
                    <id>nexus</id>
                    <url>http://192.168.1.132:8082/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>      
            <pluginRepositories>
                <!--插件库地址-->
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://192.168.1.132:8082/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                   </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>

        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Example for MySQL-->
                <sonar.jdbc.url>
                    jdbc:mysql://192.168.1.132:3306/sonarqube?useUnicode=true&amp;characterEncoding=utf8
                </sonar.jdbc.url>
                <sonar.jdbc.username>root</sonar.jdbc.username>
                <sonar.jdbc.password></sonar.jdbc.password>

                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                    http://192.168.1.132:9000/sonarqube
                </sonar.host.url>
            </properties>
        </profile>

    </profiles>


使用 Maven 分析器进行分析,命令:
纯 Maven 命令:mvn clean install sonar:sonar
MyEclipse 中执行:clean install sonar:sonar
(如果你是第一次运行此命令,看执行日志你会发现它会先下载 sonar-runner 等插件)
成功执行完分析命令后便可到 Web Server 中查看代码质量分析结果数据。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值