touch sonar-project.properties
編輯此文件vim sonar-project.properties
,內容以下:mysql
# Required metadata sonar.projectKey=my:project #項目的key sonar.projectName=My project #項目顯示的名稱 sonar.projectVersion=1.0 #版本 # Path to the parent source code directory. # 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=src #項目源代碼目錄 # Encoding of the source code sonar.sourceEncoding=UTF-8 #使用的編碼格式 # Additional parameters sonar.my.property=value
sonar-runner
配置maven的setting.xml文件,位置:%MAVEN_HOME%/conf/settings.xml
sql
<profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <!-- 數據庫url --> <sonar.jdbc.url>jdbc:mysql://172.16.128.160:3306/sonar</sonar.jdbc.url> <!-- 數據庫driver --> <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver> <!-- 數據庫username --> <sonar.jdbc.username>sonar</sonar.jdbc.username> <!-- 數據庫password --> <sonar.jdbc.password>sonar</sonar.jdbc.password> <!-- sonar地址 --> <sonar.host.url>http://172.16.128.160:19000</sonar.host.url> </properties> </profile>
執行債務分析時,若報錯,而且sonar後臺日誌(%SONARQUBE_HOME%/logs/sonar.log)中有以下錯誤undefined method 'generate' for #<JSON::Ext::Generator::State:0x76afc32d>
數據庫
問題緣由:Sonar後臺有Ruby on Rails工程,會用到Ruby的API,這個是Ruby的異常。因爲部署的服務器恰好也裝過Ruby版本,致使了調用本身安裝的Ruby,而不是Sonar內嵌的Ruby,致使出現錯誤vim
解決方案:在sonar的啓動腳本soanr.sh的開頭加入unset GEM_PATH ,在從新啓動便可,經過這個命令能夠保證每次啓動的時候使用sonar內置的ruby版本ruby