Installation and use of sonar server and client

This article will explain the installation of sonar:
Environment 1.JDK: 1.8.0_60
   2.sonarqube: sonarqube-5.4 version server (mysql5.5 and above)
   3.sonar-runner: sonar-runner-2.3 client
   4. Operating system win8 64-bit The
first step : sonarqube-5.4 can be used after decompression, first configure the configuration file.
Configuration:
1. sonar.properties in sonarqube-5.4\conf
1).mysql: First create a database sonar, where root refers to the user who can access this library.
sonar.jdbc.username=root
sonar.jdbc.password=root
sonar.jdbc.url=jdbc:mysql://127.0.0.1:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
2.Web start access port:
sonar.web.port=9000
/sonarqube-5.4/bin/windows-x86-64/StartSonar.bat start
3.sonarqube-5.4/logs You can see the startup log
When you see that Web server is startedHTTP connector enabled on port 9000Process[web] is up, it means that it is started.
Browser input: http://127.0.0.1:9000/
4. Plug-in installation
1) Enter http://127.0.0.1:9000/ above, the default username and password: admin/admin
Click the configuration menu bar - "System -" The update center can download plug-ins: Chinese, checkstyle, etc., when the download fails. Manual installation is optional.
2). Manual installation: git URL: https://github.com/SonarQubeCommunity
realease Download the jar, place it under sonarqube-5.4/extensions/plugins, restart sonarqube and it will be installed.
2. Step 2: Unzip sonar-runner-2.3
and configure environment variables to path. SONAR_RUNNER_HOME: Add %SONAR_RUNNER_HOME%\bin to
D:\Program Files\sonar-runner-2.3 path; 3. Add configuration file sonar-project.properties # Root project information sonar.projectKey=allProjects sonar. projectName=allProjects





sonar.projectVersion=1.0.0

# Some properties that will be inherited by the modules
sonar.sources=src

# List of the module identifiers
sonar.modules=a,b,c

# Properties can obviously be overriden for
# each module - just prefix them with the module ID
a.sonar.projectName=a1
b.sonar.projectName=b1
c.sonar.projectName=c1
ok!配置完成

下面使用sonar进行代码分析了:
第一种方法:
maven:在settings.xml配置sonar中配置
<profile>
    <id>sonar</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
        <sonar.jdbc.url>
            jdbc:mysql://[sonar_db_host]:3306/sonar?useUnicode=trueamp;characterEncoding=utf8
        </sonar.jdbc.url>
        <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver >
        <sonar.jdbc.username>root</sonar.jdbc.username>
        <sonar.jdbc.password>root</sonar.jdbc.password>
        <sonar.host.url>[SonarQube_host]</sonar.host.url >
    </properties>
</profile>
Then use the maven method, goals are sonar:sonar The first sonar represents the sonar plugin of maven, and the second sonar represents the sonar goal in the sonar plugin.
ok


The second method:
described before The sonar-runner-2.3 client is installed and environment variables are also configured.
So you can directly use the command line to enter the project code directory where the code needs to be analyzed (the sonar-project.properties file is configured in the directory, otherwise it will report an error unknown Unable to load component class org.sonar.batch.scan.ProjectLock You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.projectVersion), execute sonar-runner ok.

The third method: use the continuous integration tool jenkins/hudson For
detailed operations, see the installation and use of hudson article!


Remarks reference website:
maven plugin:
http://www.infoq.com/cn/news/2011/05/xxb-maven-8-plugin
http://www.infoq.com/cn/news/2011/04/ xxb-maven-7-plugin
sonar:
http://blog.csdn.net/yzhou86/article/details/41170669
http://www.ituring.com.cn/article/69556
Combination of maven and sonar: goals--- ->sonar:sonar
http://www.cnblogs.com/cuiliqiang/archive/2012/10/15/2725146.html

sonar principle:
http://www.cnblogs.com/cuiliqiang/archive/2012/10/17/2727024.html
sonar installation: https://my.oschina.net/jiangbianwanghai/blog/478338?p=1
checkStyle plugin Source code https://github.com/checkstyle/sonar-checkstyle
sonar plugin download: https://github.com/SonarQubeCommunity

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326267741&siteId=291194637