Qodana 2022.2 Help

GitLab CI/CD

Basic Example

To add a Qodana runner to a GitLab CI/CD pipeline, use the following configuration sample (.gitlab-ci.yml):

stages: - qodana qodana: stage: qodana only: - main - merge_requests image: name: jetbrains/qodana-js:2022.2-eap entrypoint: [""] variables: QODANA_REMOTE_URL: git@$CI_SERVER_HOST:$CI_PROJECT_PATH.git QODANA_BRANCH: $CI_COMMIT_BRANCH QODANA_REPO_URL: $CI_PROJECT_URL QODANA_JOB_URL: $CI_JOB_URL script: - qodana --save-report --results-dir=$CI_PROJECT_DIR/qodana --report-dir=$CI_PROJECT_DIR/qodana/report artifacts: paths: - qodana

Using this configuration, Qodana will inspect the main branch and all merge requests coming to your repository.

Exposing a Qodana report

To make a report available in any given merge request, you can use the expose_as keyword and change the path to the artifacts (.gitlab-ci.yml):

stages: - qodana qodana: stage: qodana only: - main - merge_requests image: name: jetbrains/qodana-<linter> entrypoint: [""] variables: QODANA_REMOTE_URL: git@$CI_SERVER_HOST:$CI_PROJECT_PATH.git QODANA_BRANCH: $CI_COMMIT_BRANCH QODANA_REPO_URL: $CI_PROJECT_URL QODANA_JOB_URL: $CI_JOB_URL script: - qodana --save-report --results-dir=$CI_PROJECT_DIR/qodana --report-dir=$CI_PROJECT_DIR/qodana/report artifacts: paths: - qodana/report/ expose_as: 'Qodana report'

Assuming that you have configured your pipeline in a similar manner, this is what it may look like:

  1. Qodana report affiliated with a pipeline in a merge request

    Qodana report affiliated with a pipeline in a merge request
  2. Available actions for a given exposed Qodana artifact

    Available actions for a given exposed Qodana artifact

Consider using a fail threshold to make the build fail when a certain number of problems is reached, and baseline mode, in which each new Qodana run is compared to some initial run selected as a "baseline". Running as non-root is also supported.

Last modified: 21 November 2022