美文网首页
Jenkins integration with SonarQu

Jenkins integration with SonarQu

作者: MuscleKai | 来源:发表于2018-03-01 17:26 被阅读0次

    最近工作不是很忙,试着用Jenkins集成Sonar,来帮项目做一个continuous的代码质检。

    本身操作很简单,但还是遇到了一些settings的问题。

    首先需要下载的东西list:

    Jenkins

    jenkins plugin 里面下载SonarQube plugin

    SonarQube

    SonarQube Scanner

    MySql

    环境变量配置:

    SONAR_HOME

    SONAR_SCANNER_HOME

    MYSQL_HOME

    ** 别忘记path也要更新

    配置 my.ini

    [client]

    port=3306

    default-character-set=utf8

    [mysqld]

    port=3306

    character_set_server=utf8

    basedir=D:\\mysql-5.7.20-winx64

    datadir=D:\\mysql-5.7.20-winx64\\data

    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

    skip-grant-tables

    配置 sonar.properties

    sonar.jdbc.username=root

    sonar.jdbc.password=root

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

    sonar.jdbc.driverClassName:com.mysql.jdbc.Driver

    sonar.web.host=localhost

    sonar.web.context=/

    sonar.web.port=9000

    配置 sonar-scanner.properties

    sonar.sourceEncoding=UTF-8

    sonar.projectKey=my:project

    sonar.projectName=My project

    sonar.projectVersion=1.0

    sonar.sources=D:/workspace/game-open-platform-api/src

    sonar.java.binaries=D:/workspace/game-open-platform-api/target/classes

    启动Jenkins:(在你的jenkins的path)

    $ java -jar jenkins.war--httpPort=1081

    开始配置 Jenkins

    首先创建一个item, 然后完成下面两个配置。这里只说git的代码。

    1. Global tool configuration

    2. Configure System


    配置完,就可以执行build now检查项目代码了。

    当然你还可以自己去set执行build的频率,和email notification。这些都比较straightforward就不在这写了。

    另外,如果不集成jenkins,直接在项目的path下,启动Sonar Scanner即可。然后打开localhost:9000就能看到分析结果。

    windows通过cmd

    $ sonar-scanner

    相关文章

      网友评论

          本文标题:Jenkins integration with SonarQu

          本文链接:https://www.haomeiwen.com/subject/jdfnxftx.html