(声纳立方体的当前版本为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仪表板上看到一个新条目。