Search code examples
jenkinssonarqubejenkins-pipelinecode-analysis

When is the best moment to execute SonarQube


I´m starting to define my software lifecycle with Jenkins Pipelines but I have a doubt with SonarQube.

When is the best moment to execute SonarQube? Before compile the source code or after with the generated artifact?.

I'm a bit lost with this.

Thank you very much!


Solution

  • Generally the best moment to analyze is after compilation. Why?

    • SonarSource analyzers (SonarJava, SonarJS, SonarCFamily, ...) assume compilable code
    • Some analyzers (SonarJava) use byte code as part of the analysis

    So in general you'll get both a better experience and a better analysis if you compile first.