问题描述
我正在尝试让 Jenkins 作为构建后步骤运行 Sonar.
I am attempting to get Jenkins to run Sonar as a post-build step.
Jenkins 运行 SonarRunner [1] 但这失败了:
Jenkins runs SonarRunner [1] but this fails with:
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
如果我运行 mvn sonar:sonar
[2] 而不是它可以正常工作.听起来 SonarRunner 几乎忽略了 pom.xml.如何让 SonarRunner 从 Maven 获取这些属性?
If I run mvn sonar:sonar
[2] instead it works fine. It almost sounds like SonarRunner is ignoring pom.xml. How do I get SonarRunner to pick up these properties from Maven?
[1] /Users/builds/.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Default_Sonar_Runner/bin/sonar-runner -Dsonar.jdbc.url=jdbc:h2:tcp://myServer:1009/sonar -Dsonar.host.url=http://myServer/sonar/-Dsonar.projectBaseDir=/Users/builds/.jenkins/workspace/myProject
[2] mvn sonar:sonar -Dsonar.jdbc.url=jdbc:h2:tcp://myServer:1009/sonar -Dsonar.host.url=http://myServer/sonar/-Dsonar.projectBaseDir=/Users/builds/.jenkins/workspace/myProject
推荐答案
浪费一个晚上的好方法...
What a nice way to waste an evening...
根据 此 Sonar Runner 不适用于 Maven 项目.事实证明,您应该在构建后操作"(而不是构建后步骤")下查看声纳".请参阅此处了解更多信息.
According to this Sonar Runner is not meant for Maven projects. It turns out you're supposed to look under "Post-Build Actions" (not "Post-Build Steps") and you will find "Sonar". See here for more information.
这篇关于SonarRunner 找不到 sonar.projectKey、sonar.projectName、sonar.projectVersion、sonar.sources的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!