| 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. |
Issue tracker integrationTo create a TeamCity plugin for custom issue tracking system (ITS), you have to implement the following interfaces (all from jetbrains.buildServer.issueTracker package):
The main entity is a provider (i.e. connection to the ITS), responsible for parsing, extracting and fetching issues from the ITS. Here is a brief description of the strategy used in TeamCity in respect to ITS integration: The provider has a number of parameters, configured from admin UI. These parameters are passed using the properties map (a map string -> string). Commonly used properties include provider name, credentials to communicate with ITS, or regular expression to parse issue ids. You don't have to worry about storing the properties in XML files, server does that. Provider registration is done by the TeamCity administrator in the web UI, and the responsibility for it lies mostly on TeamCity server. The plugin must only provide a JSP used for creation/editing of the provider (see details below). Plugin development overviewA brief summary of steps to be done to create and add a plugin to TeamCity.
Reusing default implementationCommon code of Jira, Bugzilla and YouTrack plugins can be found in Abstract* classes in the same package:
AbstractIssueProvider implements a simple caching provider able to extract the issues from the string based on a regexp. In most cases you just need to derive from it and override few methods. A simple derived provider class can look like this: Providers like Bugzilla might need to override extractId method, because the mention of issue id (in comment) and the id itself can differ. For instance, suppose the issues are referenced by a hash with a number, e.g. #1234; the regexp is "#(\d{4})" (configurable); but the issues in ITS are represented as plain integers. Then the provider must extract the substrings matching "#(\d{4})" and return the first groups only. You should implement it in extractId method: The factory code is very simple as well, for example: IssueFetcher is usually the central class performing plugin-specific logic. You have to implement getIssue method, which connects to the ITS remotely (via HTTP, XML-RPC, etc), passes authentication, retrieves the issue data and returns it, or reports an error. Example: You need to implement how to compose the server URL and how do you parse the data out of XML (HTML). AbstractIssueFetcher will take care about caching, errors reporting and everything else. Plugin UIThe only mandatory JSP required by TeamCity is editIssueProvider.jsp (the full path must be /plugins/myName/admin/editIssueProvider.jsp, that is, the plugin should have the jsp available /admin/editIssueProvider.jsp of its resources). This JSP is requested when the user opens the dialog for editing (or creating) the issue provider. In most cases it just renders the provider properties, or returns the form for filling them. You can see the example in /plugins/youtrack/admin/editIssueProvider.jsp. |
3 Comments
comments.show.hideDec 25, 2009
Yegor Yarko
Let's consider adding an example plugin into our external Subversion repository.
Let's add an overview note that covers all that should be done for the plugin to work (implement interfaces, add jsp, use appropriate layout in the plugin, deploy the plugin).
I also believe plugin name should be consistently referenced in all the places.
Should "myName", "MyName" and "<plugin-name>" (these are references on this page) all be the same?
Dec 28, 2009
Maxim Podkolzine
I agree, an example would be nice.
As we've discussed we're not ready for now to support Trac. Redmine is a good candidate, but it has a limited doc.
Overview - ok.
Considering names: it's just a convention that plugin name ('myName') starts with a lowercase char, and type name ('MyName') starts with uppercase char, because it is shown in UI. The strict requirements are described in javadoc.
Jan 13, 2010
Yegor Yarko
Issue that addresses plugin open-sourcing: http://youtrack.jetbrains.net/issue/TW-9103