Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The SonarQube system analyzes source code for problems and reports the results, including test code-coverage statistics, to https://www.sonarcloud.io. The analyses are usually run weekly by a Jenkins job.  This section summarizes the project configuration that is required. Analyzing and reporting static source-code features requires almost no configuration, basically just naming the directory with source code. However reporting coverage requires each project's build and test steps to generate code-coverage statistics, which requires automated unit tests that can be run by Jenkins plus additional configuration.

Every sonar analysis job consists of these steps:

  1. compile source (except for interpreted languages like python, of course)
  2. run tests to generate coverage statistics
  3. analyze source code with sonar scanner
  4. gather coverage stats with sonar scanner
  5. publish code analysis and test stats to SonarCloud.io

All these steps Sonar analyses run directly on the Jenkins build minion, usually using with the Sonar steps usually implemented by a Jenkins plug-in. Projects that use a Dockerfile to create a Docker image should factor their build so that the build and test steps can be called by a docker-based build (i.e., from within the Dockerfile) and by a non-docker-based build process. In practice this usually means creating a shell script with all the necessary steps. The tricky part is installing all prerequisites, because a Docker base build image is invariably different from the Jenkins build minion image.

...