我想在没有任何构建过程的Jenkins上运行Sonar插件(我的意图是在Jenkins中集成Sonar分析并利用我们已经拥有的subversion插件和配置).
我不想运行构建过程,因为这会占用不必要的时间; 我只想让Jenkins的工作专门用于声纳分析.
你可以做到这一点.您必须使用SonarQube Runner触发分析.
转到Build部分,单击Add build step并选择Invoke Standalone Sonar Analysis
配置SonarQube分析.您可以指向现有的sonar-project.properties文件,也可以直接在"项目属性"字段中设置分析属性
使用SonarQube Runner进行分析时,您应该提供以下强制属性:
sonar.projectKey=my:project sonar.projectName=My project sonar.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插件.它只需要源文件,但如果需要可以产生更多指标和问题.