| You are viewing documentation of TeamCity 4.x, which is not the most recent released version of TeamCity. Please refer to the listing to choose another version. |
This section covers:
Developing a Page ExtensionIn TeamCity page extension is a plugin written for a specific extension point and extending existing web page functionality. In most cases page extensions only provide some additional information and a simple UI that does not require communication with the server. TeamCity contains a number of pages that can be extended in such a way. These pages provide one or more extension points which are contained in the PlaceId class. To write a page extension:
The jetbrains.buildServer.web.openapi.PageExtension interface has the following important methods that require your attention:
jetbrains.buildServer.web.openapi.SimplePageExtension class requires jetbrains.buildServer.web.openapi.PagePlaces interface as parameter, plus jetbrains.buildServer.web.openapi.PlaceId specification. Given that PlaceId is specified, you can call method register() to register this extension. You can also use SimplePageExtension class to specify your extension in Spring xml descriptor, because it has setters for all main parameters. Developing a Custom TabA number of extension points in TeamCity are custom tab extensions. For example, PlaceId.BUILD_RESULTS_TAB identifies custom tab on build results page. To add your own tab you can extend SimplePageExtension and additionally implement jetbrains.buildServer.web.openapi.CustomTab interface with two new methods:
Processing of custom tabs has some differences from usual page extensions:
In all other respects custom tabs are processed as usual page extensions. Developing a Custom ControllerSometimes page extensions provide interaction with user and require communication with server. For example, your page extension can show a form with a "Submit" button. In this case in addition to writing your own page extension, you should provide a controller which will process requests from such forms, and use path to this controller in the form action attribute (the path is a part of URL without context path and query string). To register your controller:
To simplify things your controller can extend our jetbrains.buildServer.controllers.BaseController class and implement BaseController.doHandle(HttpServletRequest, HttpServletResponse) method. With the custom controller you can provide completely new pages. Links to such pages you can add by means of page extensions. Obtaining paths to JSP filesPlugin resources are unpacked to <TeamCity web application>/plugins directory when server starts. However to construct paths to your JSP or images in Java it is recommended to use jetbrains.buildServer.web.openapi.PluginDescriptor . This descriptor can be obtained as any other Spring service. In JSP files to construct paths to your resources you can use ${teamcityPluginResourcesPath}. This attribute is provided by TeamCity automatically, you can use it like this: <img src="${teamcityPluginResourcesPath}your_image.gif" height="16" width="16" border="0">
Classes and interfaces from TeamCity web open API
|