CentOS6.8配置SonarQube Scanner配合SonarQube使用

下载最新的SonarQube Scanner压缩包 
 
1 解压缩到CentOs目录下 我的是 /usr/local/software/sonar-scanner-3.0.3.778-linux
2 <install_directory>/conf/sonar-scanner.properties:  修改对应配置文件
   根据具体的你的URL 如果配置了sonar的context端口后还需要加上Context路径     
        #----- Default SonarQube server
        #sonar.host.url=http://localhost:9000
3 Add the <install_directory>/bin directory to your path.  加入到环境变量 
    执行sonar-scanner命令出现下面表示安装成功
            usage: sonar-scanner [options]
            Options:
                 -D,--define <arg>     Define property
                 -h,--help             Display help information
                 -v,--version          Display version information
                 -X,--debug            Produce execution debug output
 
 
4 使用sonar scanner   在项目根目录下创建sonar-project.properties文件
        Create a configuration file in the root directory of the project: sonar-project.properties
         sonar-project.properties
            关键配置  projectName 项目名 sources源代码目录
# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=My project
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
 
 

 

5 在sonar-project.properties所在目录 也就是 项目根目录 执行sonar-scanner就可以扫描了
6 如果没有问题 就可以再sonar的web界面看到扫描结果了

 

SonarQube的配置详见 http://www.cnblogs.com/QuestionsZhang/p/7115116.html

 

posted @ 2017-07-04 10:15  Questions张  阅读(1307)  评论(0编辑  收藏  举报