sonarqube怎么分析php项目,php - 如何使SonarQube运行以分析PHP项目? - 堆栈内存溢出...

(声纳立方体的当前版本为6.7,但我不知道这些步骤是否保持不变。此答案考虑了5.1。)

运行容器:

sudo docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube:5.1

这提供了SonarQube的标准安装,可从以下位置访问

http://localhost:9000/

我可以通过用户名和密码admin登录,并通过以下方式安装PHP组件:

设置>系统>更新中心

(或: http://localhost:9000/updatecenter )

并搜索PHP并安装。

在那里,我可以添加PHP,并在SonarQube服务器重启后(通过docker docker stop container_id , container start container_id做到了),扩展已加载。

服务器将不会运行您的测试。 它只会显示结果。

您将需要一台专用于sonar-runner的机器,为了快速入门,您可以使用本地开发机以及从bitbucket进行本地结帐。 在该机器上安装声纳运行器。

通过以下方式下载声纳赛跑者:

$ wget http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip

并将其提取到:

~/programs/sonar-runner-2.4

在此目录中,您可以找到文件conf/sonar-runner.properties ,其中应包含:

#Configure here general information about the environment, such as SonarQube DB details for example

#No information about specific project should appear here

#----- Default SonarQube server

sonar.host.url=http://localhost:9000

#----- PostgreSQL

#sonar.jdbc.url=jdbc:postgresql://localhost/sonar

#----- MySQL

#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8

#----- Oracle

#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE

#----- Microsoft SQLServer

#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor

#----- Global database settings

sonar.jdbc.username=sonar

sonar.jdbc.password=sonar

#----- Default source code encoding

sonar.sourceEncoding=UTF-8

#----- Security (when 'sonar.forceAuthentication' is set to 'true')

sonar.login=admin

sonar.password=admin

进入项目的根目录并创建一个名为sonar-project.properties的文件:

# must be unique in a given SonarQube instance

sonar.projectKey=yourProjectKey

# this is the name displayed in the SonarQube UI

sonar.projectName=yourProject

sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.

# Since SonarQube 4.2, this property is optional if sonar.modules is set.

# If not set, SonarQube starts looking for source code from the directory containing

# the sonar-project.properties file.

sonar.sources=./classes/,./tests/

# Encoding of the source code. Default is default system encoding

sonar.sourceEncoding=UTF-8

# Encoding of the source code. Default is default system encoding

sonar.sourceEncoding=UTF-8

然后我跑了:

your/projects/dir$: ~/programs/sonar-runner-2.4/bin/sonar-runner

然后,您将在SonarCube仪表板上看到一个新条目。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值