Skip to end of metadata
Go to start of metadata
You are viewing documentation of TeamCity 6.5.x, which is not the most recent released version of TeamCity. Please refer to the listing to choose another version.
Search

Table of Contents

The Inspections Build Runner is intended to run code analysis based on IntelliJ IDEA inspections for your project. IntelliJ IDEA's code analysis engine is capable of inspecting your Java, JavaScript, HTML, XML and other code and allows to:

  • Find probable bugs
  • Locate "dead" code
  • Detect performance issues
  • Improve code structure and maintainability
  • Ensure the code conforms to guidelines, standards and specifications

Refer to IntelliJ IDEA documentation for more details.

Icon

In order to run inspections for your project you should have either an IntelliJ IDEA project file (.ipr)/project directory (.idea), or Maven2 pom.xml of your project checked into your version control. Note, that if you want to use pom.xml, you need to open it in IntelliJ IDEA and configure inspection profiles, as described in IntelliJ IDEA documentation. IntelliJ IDEA will save your inspection profiles in corresponding folder, make sure you have it checked into your version control. Then specify the paths to inspection profiles while configuring this runner.

This page contains reference information about the Inspections Build Runner fields:

IntelliJ IDEA Project Settings

Option

Description

Project file type

To be able to run IntelliJ IDEA inspections on your code, TeamCity requires either IntelliJ IDEA project file/directory, or Maven2 pom.xml to be specified here.

Path to the project

Depending on what type of project you have selected in the Project file type, specify here:

  • For IntelliJ IDEA project: the path to the project file (.ipr) or path to the project directory (root directory of the project that contains .idea folder).
  • For Maven2 project: path to the pom.xml file.
    This information is required by this build runner to understand the structure of the project.
    Icon

    Specified path should be relative to the checkout directory.

Detect global libraries and module-based JDK in the *.iml files

This option is available, if you use IntelliJ IDEA project to run the inspections. In IntelliJ IDEA module settings are stored in *.iml files, thus if this option is checked, all the module files will be automatically scanned for references to the global libraries and module JDKs when saved. This helps you ensure all references will be properly resolved.

Warning

Icon

When this option is selected, the process of opening and saving the build runner settings may become time-consuming, because it involves loading and parsing all project module files.

Check/Reparse Project

Click this button to reparse your Maven2/IntelliJ IDEA project and import build settings right from the project, for example the list of JDKs.

Icon

If you update your project settings in IntelliJ IDEA or in the pom.xml - add new jdks, libraries, don't forget to update build runner settings by clicking Check/Reparse Project.

Working directory

Enter a path to a build working directory, if it differs from the build checkout directory. Optional, specify if differs from the checkout directory.

Unresolved Project Modules and Path Variables

This section is displayed, when an IntelliJ IDEA module file (.iml) referenced from IntelliJ IDEA project file:

  • cannot be found
  • allows you to enter the values of path variables used in the IPR-file.

To refresh values in this section click Check/Reparse Project.

Option

Description

<path_variable_name>

This field appears, if the project file contains path macros, defined in the Path Variables dialog of IntelliJ IDEA's Settings dialog. In the Set value to field, specify a path to project resources, to be used on different build agents.

Project JDKs

This section provides the list of JDKs detected in the project.

Option

Description

JDK Home

Use this field to specify JDK home for the project.

Icon

When building with the Ipr runner, this JDK will be used to compile the sources of corresponding IDEA modules. For Inspections and Duplicate Finder builds, this JDK will be used internally to resolve the Java API used in your project.
To run the build process itself the JDK specified in the JAVA_HOME environment variable will be used.

JDK Jar File Patterns

Click this link to open a text area, where you can define templates for the jar files of the project JDK. Use Ant rules to define the jar file patterns.
The default value is used for Linux and Windows operating systems:

For Mac OS X, use the following lines:

IDEA Home

If your project uses the IDEA JDK, specify the location of IDEA home directory

IDEA Jar Files Patterns

Click this link to open a text area, where you can define templates for the jar files of the IDEA JDK.

Icon

You can use references to external properties when defining the values, like %system.idea_home% or %env.JDK_1_3%. This will add a requirement for the corresponding property.

Java Parameters

Option

Description

JDK home path

Use this field to specify the path to your custom JDK which should be used to run the build. If the field is left blank, the path to JDK Home is read either from the JAVA_HOME environment variable on agent computer, or from env.JAVA_HOME property specified in the build agent configuration file (buildAgent.properties). If these both values are not specified, TeamCity uses Java home of the build agent process itself.

JVM command line parameters

Specify the desired Java Virtual Machine parameters, for example maximum heap size. These settings are passed to the JVM used to run your build.
Example:

Inspection Parameters

In IntelliJ IDEA-based IDEs, the code inspections reported are configured by an inspection profile.
When running the inspections in TeamCity you can specify the inspection profile to use. You need to configure the inspection profile in IntelliJ IDEA-based IDE and then specify it in TeamCity.

Please follow these rules when preparing inspection profiles:

  • if your inspection profile uses scopes, make sure the scopes are shared;
  • lock the profile (this ensures that inspections that are present in TeamCity, but not enabled in your IDEA installation will not be run by TeamCity);
  • ensure the profile does not have inspections provided by plugins not included into default IntelliJ IDEA Ultimate distribution (otherwise they will just be ignored by TeamCity);
  • for best results edit the inspection profile in the IntelliJ IDEA of the same version as used by TeamCity (can be looked up in the inspection build log).

The logic of selecting an inspection profile is as follows (first found matching profile is used):

  • if the path to the inspection profile is specified, the profile is tried to be loaded from the file. If the loading fails, default project profile is used
  • if the name of the inspection profile is specified, the profile is searched for in the project's shared profiles and if not found, in the local settings (under .IntelliJIdeaXX/config/inspection directory)
  • default profile of the project is used

Option

Description

Inspections profile path

Use this text field to specify the path to inspections profiles file relative to the project root directory. Use this field only if you do not want to use shared project profile specified with "Inspections profile name".

Inspections profile name

Enter the name of the desired shared project profile. If the field is left blank and no profile path is specified default project profile will be used.

Maximum error limit

Fail build if the specified number of errors is exceeded. By default first error that occurs will fail the build.

Warnings limit

Fail build if the specified number of warnings is exceeded. Leave blank if there is no limit.

Icon

If you need to restrict the sources scope on which to run the Inspections runner, you can specify additional JVM parameters (in the JVM command line parameters field).

Example:

  • all patterns must end with either ** or * (this effectively limits the patterns to only the directories level, they do not support file-level patterns)
  • includes have precedence over excludes
  • references to modules can be included as [module_name]/<path_within_module>
  • "include" pattern has a special behavior (due to underlying limitations): it includes the directory specified and all the files residing directly in the directories above the one specified. (in the example above, testData/basicTest.xml file will be included into the analysis)
Icon

For the file paths to be reported correctly, "References to resources outside project/module file directory" option for the project and all modules should be set to "Relative" in IDEA project.