Custom Build Runner

Search
Searching TeamCity 4.x Documentation
Table of Contents

Writing a Custom Build Runner

Agent-side Part

Implement jetbrains.buildServer.agent.BuildRunner interface (you may also extend GenericProgramRunner or even JavaProgramRunner helpers for this). To log your messages, you may obtain instance of ServerLogger singleton (you may also use ServerLoggerFacade for convinience).

Server-side Part

Build agent plugin should also provide server side jar with a class implementing jetbrains.buildServer.serverSide.RunType interface. The implementation of the RunType interface must be registered in the jetbrains.buildServer.serverSide.RunTypeRegistry. You can do this in the constructor of the RunType implementation, like this:

public class CustomRunTypeImpl {
...
public CustomRunType(RunTypeRegistry runTypeRegistry) {
runTypeRegistry.registerRunType(this);
}
...
}
Please note that you should also provide the plugin descriptor file named build-server-plugin-<unique_plugin_name>.xml which will contain reference to the RunType implementation:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-autowire="constructor">
<bean id="customRunType" class="some.package.CustomRunTypeImpl"/>
</beans>

Support for Risk Group Tests Reordering

In TeamCity, you can instruct the system to run risk group tests before any others.

To implement risk group tests reordering feature for your own custom runner, TeamCity provides following special properties:

  • teamcity.tests.runRiskGroupTestsFirst — this property value contains groups of tests to run before others. Accordingly there are two groups: recentlyFailed and newAndModified. If more than one group specified they are separated with comma. This property is provided only if corresponding settings are selected on build runner page.
  • teamcity.tests.recentlyFailedTests.file — this property value contains full path to a file with recently failed tests. The property is provided only if recentlyFailed group is selected. The file contains tests separated by new line character. For Java like tests full class names are stored in the file (without test method name). In other cases full name of the test will be stored in the file as it was reported by the tests runner.
  • teamcity.build.changedFiles.file — this property is useful if you want to support running of new and modified tests in your tests runner. This property contains full path to a file with information about changed files included in the build. You can use this file to determine whether any tests were modified and run them before others. The file contains lines separated by new line. Each line corresponds to one file and has the following format:
    <relative file path>:<change type>:<revision>

    where:

    • <relative file path> is a path to a file relative to the current checkout directory.
    • <change type> is a type of modification and can have the following values: CHANGED, ADDED, REMOVED, NOT_CHANGED, DIRECTORY_CHANGED, DIRECTORY_ADDED, DIRECTORY_REMOVED
    • <revision> is a file revision in repository. If file is a part of change list started via remote run then string <personal> will be written instead of file revision.
  • teamcity.build.checkoutDir — this property contains path to a build checkout directory. It is useful if you need to convert relative paths to modified files to absolute ones.

Labels