Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sonarqube code detection

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Install the java environment

Slightly

2. Download the sonarqube package

Download address of sonarqube and sonar-runner: http://www.sonarqube.org/downloads/

Extract the downloaded package to the specified directory and configure the environment variables:

Mkdir / usr/local/sonarunzip-o sonarqube-5.1.1.zip-d / usr/local/sonarunzip-o sonar-runner-dist-2.4.zip-d / usr/local/sonarvim / etc/profileexport JAVA_HOME=/usr/java/latestexport CLASSPATH=/usr/java/latest/lib:/usr/java/latest/jre/libexport SONAR_HOME=/usr/local/sonar/sonarqube-5.1.1export SONAR_RUNNER_HOME=/usr/local/sonar/sonar-runner-2.4export PATH=$PATH:$JAVA_ HOME/bin:$JAVA_HOME/jre/bin:$RONAR_RUNNER_HOME/bin

3. Configure mysql, create sonar database, and authorize

Mysql > create database sonar;mysql > grant all on sonar.* to sonar@'localhost' identified by 'sonar'

4. Modify the configuration file of sonarqube

Vim / usr/local/sonar/sonarqube-5.1.1/conf/sonar.propertiessonar.jdbc.username=sonarsonar.jdbc.password=sonarsonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

5. Modify the configuration file of sonar-runner

Vim / usr/local/sonar/sonar-runner-2.4/conf/sonar-runner.propertiessonar.host.url= http://0.0.0.0:9000sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8sonar.jdbc.username=sonar sonar.jdbc.password=sonarsonar.sourceEncoding=UTF-8sonar.login=adminsonar.password=admin

6. Start sonarqube

Cd / usr/local/sonar/sonarqube-5.1.1/bin/linux-x86-64/./sonar.sh start

7. Install the plug-in

Open sonarqube through http://IP:9000 and log in. You can see various plug-ins under settings-- > system-- > update center. You can install them directly. Chinese plug-ins and php plug-ins are all installed in this way.

8. Use sonar-runner to analyze php source code

Create a sonar-project.properties configuration file in the root directory of the project source code

Sonar.projectKey=apps # projectKey must be unique. You can specify sonar.projectName=apps # specify the name of project, sonar.projectVersion=1.0 # project version number, and specify sonar.sources=. at will. # Source code directory,. Represents the current directory

Change to the directory where the project is located and perform the analysis:

/ usr/local/sonar/sonar-runner-2.4/bin/sonar-runner

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 228

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report