TeamCity - Qodana functionality
- Get link
- X
- Other Apps
Starting from 2022.04
, Qodana functionality is available in TeamCity by default. 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.
Currently, running Qodana on Windows-based build agents of TeamCity is not supported.
Add a Qodana runner
Assuming that you have already created your project and configured your build, follow the steps below.
Navigate to your build configuration.
On the build configuration page, select Build Steps from the Edit configuration list.
On the Build steps page, click the Add build step button.
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.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 Qodana report availability in the Test tab of TeamCity UI. Using this option, you can view codebase problems along with other problems detected.
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 inspectionsEmbedded profile
lets you select from any available profiles, see the Default profiles section for detailsPath 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, see the Shell commands section for details.
Additional Qodana arguments lets you extend the default Qodana functionality, see the Docker image configuration page for details.
Click Save. Now you can run Qodana in the build.
Configure the project token
The project token is required by the paid Qodana linters, and is optional for using with the Community linters. You can see these sections to learn how to generate the project token:
The Onboarding section explains how to get the project token generated while first working with Qodana Cloud
The Manage a project section explains how to create a project in the existing Qodana Cloud organization
To apply the generated project token, follow these steps:
In the TeamCity UI, open the build step that will run Qodana.
In the Cloud Token field, insert the Qodana Cloud token value.
(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.
Navigate to your build configuration.
On the build configuration page, select Build Steps from the Edit configuration list.
On the Build steps page, click the Add build step button.
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.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: ProhibitedDependencyLicense EOM
Verify inspection results
Now that you have configured and run the build, you can observe inspection results in the TeamCity UI.
Navigate to the project build page. In the Overview tab, click the build entry.
On the build page, navigate to the Qodana tab to find the inspection report. To learn more about Qodana reports, see the Inspection report section of this documentation.
- Get link
- X
- Other Apps
Comments
Post a Comment