Server-side plugins are delivered as a set of jar files, one of which contains the plugin descriptor file. Such plugins can process data which is logged from build agents in some specific way, provide additional web content, create custom notifiers, etc.
Since TeamCity and all plugins are initialized by Spring, most of the TeamCity services are provided using autowiring feature of Spring framework. In brief to obtain a reference to a service in your plugin (defined as a Spring bean), you can simply create constructor accepting this service. Spring will pass implementation of the service to this constructor automatically. The plugin code should be active - plugin components should register themselves in various TeamCity managers and components.
If you extend TeamCity's web UI, please also refer to Web UI Extensions.
In this section:
Plugin Descriptor
The plugin descriptor file is named build-server-plugin-<unique_plugin_name>.xml and contains component definitions according to Spring configuration file syntax.
Base configuration of the server can be found in /WEB-INF/lib/server.jar!/META-INF/buildServerSpring.xml and /WEB-INF/buildServerSpringWeb.xml files.
Example descriptor:
<?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="emailNotificator"
class="jetbrains.buildServer.notification.email.EMailNotificator"/>
<bean id="emailNotificatorSettingsController"
class="jetbrains.buildServer.controllers.email.EMailNotificatorSettingsController"/>
</beans>
Useful Services
Server provides a number of useful services that can be provided by Spring. The following services are used most frequently:
| Class |
Description |
| jetbrains.buildServer.util.EventDispatcher <jetbrains.buildServer.serverSide.BuildServerListener> |
Allows to register server listeners (jetbrains.buildServer.serverSide.BuildServerListener). Server listener is notified about many aspects of server lifecycle, including builds start/running/finishing, changes appearance or object model modifications. |
| jetbrains.buildServer.serverSide.ProjectManager |
Locate projects and build configurations using this class. |
| jetbrains.buildServer.serverSide.RunningBuildsManager |
Incapsulates methods allowing to obtain running builds. |
| jetbrains.buildServer.serverSide.BuildAgentManager |
Provides access to build agents. |
| jetbrains.buildServer.serverSide.BuildQueue |
Provides access to build queue. |
| jetbrains.buildServer.serverSide.SBuildServer |
Contains useful methods allowing to locate builds across all projects. |
The following interfaces represent server objects model:
| Class |
Description |
| jetbrains.buildServer.serverSide.SProject |
Represents a project. |
| jetbrains.buildServer.serverSide.SBuildType |
Represents a build configuration. |
| jetbrains.buildServer.vcs.SVcsRoot |
Represents a VCS root (VCS connection settings). |
| jetbrains.buildServer.serverSide.SBuild |
An instance of a build (running or finished). |
| jetbrains.buildServer.serverSide.SRunningBuild |
An instance of a running build |
| jetbrains.buildServer.serverSide.SFinishedBuild |
An instance of a finished build |
| jetbrains.buildServer.serverSide.SBuildAgent |
An instance of a build agent. |
| jetbrains.buildServer.users.UserModel |
Various user-related operations. |
| jetbrains.buildServer.users.SUser |
Represents a single user. |
There is a number of services especially designed to support TeamCity plugins. In most cases these services allow to register plugins in the server:
| Class |
Description |
| jetbrains.buildServer.serverSide.RunTypeRegistry |
Ue this service to register build runner descriptor (jetbrains.buildServer.serverSide.RunType). RunType provides information about build runner on the server, and it also provides a UI for build runner settings customization. |
| jetbrains.buildServer.vcs.VcsManager |
Allows to register custom version control integration plugin (jetbrains.buildServer.vcs.VcsSupport) |
| jetbrains.buildServer.notification.NotificatorRegistry |
Use this calss to register custom notifier (jetbrains.buildServer.notification.Notificator) |
| jetbrains.buildServer.web.openapi.PagePlace |
This service allows you to customize existing pages in the TeamCity web UI (jetbrains.buildServer.web.openapi.PageExtension) |
| jetbrains.buildServer.web.openapi.WebControllerManager |
register custom web controllers with help of this service. Custom controller allows you to provide completely new pages to TeamCity server UI. |
| jetbrains.buildServer.serverSide.auth.LoginConfiguration |
Allows to register custom authentication modules |
| jetbrains.buildServer.serverSide.ServerExtensionHolder |
Allows to register additional custom extensions; these extensions may affect some aspects of TeamCity functionality. For example, you can register custom jetbrains.buildServer.serverSide.DataCleaner which will be invoked when data cleanup process is started. |
Server-side Extension Points
TeamCity server has a number of extension points, where a plugin can provide some additional functionality. An extension point is defined in terms of interface, which extends jetbrains.buildServer.serverSide.ServerExtension. There are several such interfaces/extension points. To register an extension, a plugin should invoke method jetbrains.buildServer.serverSide.{}ServerExtensionHolder{}#registerExtension(extension_class, pluginCode, extensionObject).
Here is a list of some extension points:
| jetbrains.buildServer.serverSide.ParametersPreprocessor |
Allows to modify build and run parameters which are sent to TeamCity server before build start. |
| jetbrains.buildServer.serverSide.DataCleaner |
Allows to register additional clean-up hooks for the case when build is removed. |
| jetbrains.buildServer.serverSide.GeneralDataCleaner |
Allows to register global additional cleanup procedures which are called once per cleanup. |
| jetbrains.buildServer.serverSide.MainConfigProcessor |
Allows to read/write global TeamCity data, which are saved in XML file main-config.xml |
| jetbrains.buildServer.serverSide.TextStatusBuilder |
Allows to modify build status description line, for example, Tests passed: 343, Fitnesse: 23 |