配置文件,在我的情况下,始终在应用程序库,然后从詹金斯工作作为$ WORKSPACE叫/ sonar-project.properties
文件的内容(例如):
# Required metadata
sonar.projectKey=<project-key>
sonar.projectName=<project-name>
sonar.projectVersion=<project-version>
# Comma-separated paths to directories with sources (required)
sonar.sources=src
sonar.exclusions=src/vendor/**/*
# Language
sonar.language=php
# Encoding of the source files
sonar.sourceEncoding=UTF-8
sonar.php.coverage.reportPath=src/coverage-clover.xml #change path to location of your test report
sonar.php.tests.reportPath=src/unitreport.xml #change path to location of your test report
在詹金斯/全球工具配置您必须添加一个Sonarqube扫描仪,看起来是这样的:
而在管理詹金斯/配置系统,您必须添加您的Sonarqube服务器“绝密Sonarqube”配置是这样的:
在工作本身你:
def scannerHome = tool 'azure-tools-sonarqube' #This is the scanner you added
withSonarQubeEnv('redacted Sonarqube') { #This is the server you added
sh "${scannerHome}/bin/sonar-scanner"
}
感谢您的回答。我拥有管理Jenkins /配置系统的所有Sonarqube配置。另外我遇到的错误是由于jdk1.7。在我将其更新到jdk 1.8后,错误得到解决。但现在我又遇到了另一个错误 - 在SonarQube扫描仪执行过程中出错。错误:您必须为'未知'定义以下必需属性:sonar.projectKey,sonar.projectName,sonar.projectVersion,sonar.sources。 正如你在答案中提到的那样,我们可以在sonar-project.properties中拥有这些属性,但有没有办法在Groovy Script中直接指定这些属性。 –
您可以在'def scannerHome'行之前的相同执行步骤中定义所有特性。性质如将有在配置文件中的相同: sonar.projectKey = sonar.projectName = <项目名称> sonar.projectVersion = 1.0 //#逗号分隔的路径与源目录(必需) sonar.sources = SRC sonar.exclusions = SRC /供应商/ **/* //#语言 sonar.language = PHP 源文件的 //#编码 sonar.sourceEncoding = UTF-8 –
如果它帮助你解决你的问题,请将答案标记为已接受:) –