问答:是否可以在没有任何构建过程的情况下在Jenkins上运行Sonar插件
你可以做到这一点.您必须使用SonarQube Runner触发分析.
转到Build部分,单击Add build step并选择Invoke Standalone Sonar Analysis
配置SonarQube分析.您可以指向现有的sonar-project.properties文件,也可以直接在”项目属性”字段中设置分析属性
使用SonarQube Runner进行分析时,您应该提供以下强制属性:
sonar.projectKey=my:projectsonar.projectName=My projectsonar.projectVersion=1.0# Path to the parent source code directory.# Path is relative to the sonar-project.properties file. Replace “” by “/” on Windows.# Since SonarQube 4.2, this property is optional. If not set, SonarQube starts looking for source code# from the directory containing the sonar-project.properties file.sonar.sources=src
在这种情况下,您可能会错过一些规则违规(如FindBugs),因为未提供.class文件.您必须手动构建项目并将sonar.binaries属性设置为类文件.如果您从不想构建项目,那么您也可以使用SonarQube的SourceMeter插件.它只需要源文件,但如果需要可以产生更多指标和问题.