Qodana 2021.3 Help

TeamCity

Starting from 2022.04, Qodana functionality is available in TeamCity by default. To start using it, these prerequisites need to be met:

Add a Qodana runner

Assuming that you have already created your project and configured your build, follow the steps below.

  1. Navigate to your build configuration.

    Navigating to the build configuration
  2. On the build configuration page, select Build Steps from the Edit configuration list.

    Navigating to the step configuration

  3. On the Build steps page, click the Add build step button.

    Creating a new build step

  4. From the Runner type list, select Qodana as a runner. On the New Build Step page, you can configure the Qodana runner using the basic options. Otherwise, click Show advanced options to expand the list of configuration options.

    Expanding all configuration options of the Qodana runner

  5. Fill in the fields using this description.

    Step name uniquely identifies this step among other build steps.

    Execute step configures the build condition that will trigger this build step.

    Working directory sets the directory for the build process. For more information, see the TeamCity documentation. You can leave this field empty if the Checkout directory parameter is specified on the Version Control Settings tab.

    Report ID uniquely identifies the report to let you distinguish between multiple reports when several inspection steps are configured within a single build.

    The Forward reports to TeamCity Tests checkbox configures forwarding all Qodana inspection reports to TeamCity Tests for further investigation.

    Linter configures the Qodana Linter.

    Version is by default set to Latest.

    Inspection profile defines the inspection profile. For more information, see the Configure profile section. The available values are:

    • Recommended (default) is the default profile containing a preselected set of IntelliJ inspections

    • Embedded profile lets you select from any available profiles, see the Default profiles section for details

    • Path to the IntelliJ profile lets you specify the path to a custom profile. Make sure that the .idea directory containing the profile file is added to your working directory.

    You can disable certain inspections later using the qodana.yaml file or Profile settings in your HTML report.

    Additional arguments for 'docker run' configures the arguments accepted by a Docker image. For example, they can be the -d or -changes parameters. For more information about arguments, see the Examples of execution tuneup section.

    Additional Qodana arguments lets you extend the default Qodana functionality, see the Configuration options for details.

  6. Click Save. Now you can run Qodana in the build.

(Optional) Add a configuration script

Custom profile configuration for Qodana linters is stored in qodana.yaml. When using a CI system, you need to put this file to the working directory manually. Alternatively, you can write a script that will do it for you.

  1. Navigate to your build configuration.

    Navigating to the build configuration
  2. On the build configuration page, select Build Steps from the Edit configuration list.

    Navigating to the step configuration

  3. On the Build steps page, click the Add build step button.

    Creating a new build step

  4. From the Runner type list, select Command Line. On the New Build Step page, you can configure the Command Line runner using the basic options. Otherwise, click Show advanced options to expand the list of configuration options.

    Expanding all configuration options of the Command Line runner

  5. Fill in the fields using the Command Line runner description from the TeamCity documentation portal.

    In the Custom script editor, paste a script that adds a custom qodana.yaml to the working directory. In the example below, the script appends the following inspection exclusions to the configuration file:

    #!/bin/sh FILE="./qodana.yaml" /bin/cat <<EOM >$FILE exclude: - name: Annotator - name: AnotherInspectionId paths: - relative/path - another/relative/path - name: CloneFinder - name: ProhibitedDependencyLicense EOM

Verify inspection results

Now that you have configured and run the build, you can observe inspection results in the TeamCity UI.

  1. Navigate to the project build page. In the Overview tab, click the build entry.

    Navigating to the build entry

  2. On the build page, navigate to the Qodana tab to find the inspection report. To learn more about Qodana reports, see the User interface overview section of this documentation.

    Navigating to the Qodana tab

Last modified: 12 May 2022