您的位置:首页 > 编程语言

jenkins集成sonarqube代码质量跟踪分析

2016-11-04 10:12 716 查看
1. sonarqube install

     >ssh 10.90.3.84

     >wget  https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.6.3.zip

     >unzip sonarqube-5.6.3.zip -d  /usr/local/

     >ln -s  /usr/local/sonarqube-5.6.3 /usr/local/sonarqube

     >touch /etc/profile.d/sonar.sh

         SONAR_HOME=/usr/local/sonarqube/

         export SONAR_HOME 

     

2. sonarqube db  install

     CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; 

     CREATE USER 'sonar' IDENTIFIED BY 'sonar’;

     GRANT ALL ON sonar.* TO 'sonar'@'10.90.3.%' IDENTIFIED BY 'sonar';

     FLUSH PRIVILEGES;

     /usr/local/mysql/bin/mysql -h 10.90.3.81  -u sonar -p

3. sonarqube config

     >vi  /usr/local/sonarqube/conf/sonar.properties

         sonar.jdbc.username=sonar

         sonar.jdbc.password=sonar

         sonar.jdbc.url=jdbc:mysql://10.90.3.81:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

         sonar.web.context=/sonar

         sonar.web.port=9000

         sonar.sourceEncoding=UTF-8

         sonar.login=admin

         sonar.password=admin

4. sonarqube start/stop

     >./bin/linux-x86-64/sonar.sh  start/stop/restart

5. sonarqube access

     http://10.90.3.84:9000/sonar

6. sonarqube  integration

     jenkins install  sonar_plugin etc.

     method1: config  sonar server for jenkins.

     method2: config sonar server for maven. 
      >vi  /usr/local/maven/settting.xml

       <profile>  

        <id>sonar</id>  

        <activation>  

            <activeByDefault>true</activeByDefault>  

        </activation>  

        <properties>  

            <sonar.jdbc.url>jdbc:mysql://10.90.3.81:3306/sonar?useUnicode=true&characterEncoding=utf-8</sonar.jdbc.url>  

            <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>  

            <sonar.jdbc.username>sonar</sonar.jdbc.username>  

            <sonar.jdbc.password>sonar</sonar.jdbc.password>  

            <sonar.host.url>http://10.90.3.84:9000/sonar</sonar.host.url>  

        </properties>  

      </profile>  

      > mvn sonar:sonar 

参考:http://sonar.oschina.net/  开放的sonar代码质量服务平台
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: