是否可以在没有任何构建过程的情况下在Jenkins上运行Sonar插件?

时间:2014-07-09 13:30:14

标签: jenkins jenkins-plugins sonarqube

我想在没有任何构建过程的Jenkins上运行Sonar插件(我的意图是在Jenkins中集成Sonar分析并利用我们已经拥有的subversion插件和配置)。

我不想运行构建过程,因为这会占用不必要的时间;我只想让Jenkins的工作专门用于声纳分析。

1 个答案:

答案 0 :(得分:6)

你可以做到这一点。你必须triggering the analysis with the SonarQube Runner

  1. 转到Build部分,单击Add build step并选择Invoke Standalone Sonar Analysis
  2. 配置SonarQube分析。您可以指向现有的sonar-project.properties文件,也可以直接在“项目属性”字段中设置分析属性
  3. 分析with 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属性设置为类文件。如果您从不想构建项目,那么您也可以使用SourceMeter plugin for SonarQube。它只需要源文件,但如果需要,可以产生更多指标和问题。

相关问题