学习如何使用SonarQube并从here
快速安装一直到第5步。执行时我的构建失败: C:\声纳浇道\ BIN \声纳-runner.bat
我收到以下错误:
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 7.572s
Final Memory: 8M/223M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
有没有人遇到类似的情况并解决了?
答案 0 :(得分:69)
如果您有一个java项目,则必须在执行sonar runner的文件夹中创建一个sonar-project.properties文件。您必须在此文件中定义以下属性:
# Required metadata
sonar.projectKey=java-sonar-runner-simple
sonar.projectName=Simple Java project analyzed with the SonarQube Runner
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
希望这有帮助,
答案 1 :(得分:5)
对我来说,原因是:https://stackoverflow.com/a/18779516/1068411
简而言之:你应该将声纳置于"构建后动作"而不是"构建后步骤"。
答案 2 :(得分:4)
对于那些在CLI上有类似响应的人,并猜测你的设置是否正确,我的问题是从项目目录的外侧运行sonar-runner
命令。确保您的项目有cd
,然后运行命令。
答案 3 :(得分:1)
在声纳属性下面的Jenkins内部为我工作。
sonar.projectKey=MyWebApp
sonar.projectBaseDir=./MyWebApp
sonar.projectName=MyWebApp
sonar.projectVersion=1.0
sonar.sources=./src/main/java
sonar.language=java
sonar.java.binaries=.
##to avoid this exception Caused by: org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001
sonar.scm.disabled=True
sonar.sourceEncoding=UTF-8
希望它会对某人有所帮助 谢谢!