可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Learning how to use SonarQube and was doing a quick install from here
Got all the way down to step 5. My build fails when I execute: C:\sonar-runner\bin\sonar-runner.bat
I get the following error:
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.
Anyone encountered a similar situation and resolved?
回答1:
If you have a java project, you must create a sonar-project.properties file in the folder where you execute sonar runner. You must define the following properties inside this file:
# 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
Hope this helps,
回答2:
For me it was due to this: https://stackoverflow.com/a/18779516/1068411
In short: you should put sonar into "Post-Build Actions", not "Post-Build Steps".
回答3:
For those who has similar response on CLI and guess thy setupped everything correctly, my problem was running sonar-runner
command from out side of project directory. Make sure you have cd
to your project and then run the command.
回答4:
Inside Jenkins below sonar properties worked for me .
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
Hope it will help someone.
Thanks!