TeamCity
Qodana is available in TeamCity as the Qodana
build runner. To start using it, these prerequisites need to be met:
You use TeamCity as a build server for your project. If not, learn how to do it in TeamCity documentation.
Your project language is included in the list of fully supported technologies.
If you use your own TeamCity agents, make sure that Docker is installed on the agent machines and accessible by the users TeamCity is running under. TeamCity agents hosted by JetBrains already meet this condition.
Add the Qodana runner
Assuming that you have already created your project and build configuration, follow the steps below.
In the TeamCity UI, navigate to the configuration page of a build where you would like to run Qodana.
- page, navigate to the
On the
page, click the button.On the page that opens, select the
runner.On the
page, click and configure the runner:uniquely identifies this step among other build steps.
uniquely identifies this step among other build steps.
configures the build condition that will trigger this build step.
TeamCity documentation for details. You can leave this field empty if the
sets the directory for the build process, see theCheckout directory
parameter is specified on the tab.uniquely identifies the report to let you distinguish between multiple reports when several inspection steps are configured within a single build.
The Test tab of the TeamCity UI. Using this option, you can view codebase problems along with other problems detected.
checkbox configures Qodana report availability in the- configures the
is by default set toLatest
.- defines an
Recommended (default)
is one of the default profiles.Embedded profile
lets you select a default profile, see the Existing Qodana profiles section for details.Path to the IntelliJ profile
lets you specify the path to your custom profile. To use this option, make sure that you also configure the custom profile in theqodana.yaml
file.
project token generated in Qodana Cloud.
configures aShell commands section for details.
configures the arguments accepted by a Docker image, see theOptions section for details.
lets you extend the default Qodana functionality, see the
Click the
button.
Quality gate and baseline
Using the Additional Qodana arguments field of the Qodana
runner configuration, you can configure the quality gate and baseline features:
--fail-threshold <number>
option for configuring a quality gate,--baseline <path/to/qodana.sarif.json>
option for configuring a baseline.
To configure both options, in the Additional Qodana arguments field separate them using a space character:
Analyze pull requests and specific branches
Information about configuring TeamCity for analyzing pull and merge requests is available on the TeamCity documentation portal.
To learn how to analyze specific branches, see the Trigger Settings section of the TeamCity documentation.
Add a configuration script
Custom profile configuration for Qodana linters is stored in the qodana.yaml
file. 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.
In the TeamCity UI, navigate to the configuration page of a build where you would like to run Qodana.
- page, navigate to the
On the
page, click the button.On the page that opens, select the
Command line
runner.Configure the
Command line
runner as described on the TeamCity documentation portal.In the
field, paste a script that adds a customqodana.yaml
file 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: ProhibitedDependencyLicense EOM
Verify inspection results
Now that you have configured and run the build, you can examine analysis results in Qodana Cloud.
Alternatively, you can view analysis results using the TeamCity UI, follow the steps below:
Navigate to a project build page. On the
tab, click the build entry.On the build page, navigate to the Inspection report section of this documentation.
tab to find the inspection report. To learn more about Qodana reports, see the