我正在尝试让詹金斯(Jenkins)运行Sonar,作为后期构建步骤。
Jenkins运行SonarRunner [1],但这失败了:
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获得这些属性?
mvn sonar:sonar
[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
/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
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
浪费一个晚上的好方法…
根据该声纳亚军并不意味着Maven项目。事实证明,您应该在“构建后操作”下查看(而不是“构建后步骤”),然后会找到“声纳”。有关更多信息,请参见此处。