Creating an Issue Tracker Plugin

You are viewing an old version (v. 2) of this page.
The latest version is v. 6, last edited on Oct 14, 2011 (view differences | )
<< View previous version | view page history | view next version >>

Since 4.0, you can add your own test report plugin by using report plugin APIs. Normally, an typical issue tracker plugin contributes below extension points:

  • BuildTabContribution displays a tab in build page to show related issues
  • BuildSummaryContribution displays a summary section to show how many issues are related in a build in build dropdown
  • Gadget displays the related issues of a configuration in Dashboard page
  • CommentTransformer hyperlink the issues occurred in commit comment by a pattern
  • StatisticsSupport collects issues by build so that we can compare with a specified build

even more, contribute some steps to create/update issues.

You needn't write the plugin from ground up, plugin com.pmease.quickbuild.tracker.core implements and encapsulates most of them already, just follow below instructions to create an issue tracker plugin. If you are not familiar with how to set up your development environment or how to create and test a plugin, please read [plugin tutorials] and some plugin examples first. Or you may read the Redmine plugin source code directly. Below we will show you how to add a Redmine plugin.

Plugin Activator

Every issue tracker plugin needs a plugin activator. As plugin com.pmease.quickbuild.tracker.core has already done a lot of things, add it to plugin dependencies in MANIFEST.MF, and actually, in most cases, you only need this dependency.

And then, implement the activator by extending AbstractTrackerPlugin:

public class RedminePlugin extends AbstractTrackerPlugin {
    public IssueTracker createTracker() {
        return new RedmineTracker();
    }

    protected IssueCategory createCategory() {
        return new RedmineCategory();
    }

    public Class<?> getConfigurationSettingClass() {
        return RedmineSetting.class;
    }
}

It is fairly simple, and we will discuss more detailed below.

IssueTracker

IssueTracker is an interface which tell QuickBuild how to fetch issue related information from remote server:

public interface IssueTracker extends CommentTransformer {
    /**
     * Return the total issues in a build
     */
    int getIssueCount(Build build);
    
    /**
     * Get the issue pattern which will be used to match issue key in commit message
     * @return
     */
    Pattern getIssuePattern();
    
    /**
     * Extract the issue key from a matched issue key, for example: extract bug:123 to 123, #456 to 456
     * 
     * @param matched
     * @return
     */
    String extractIssueKey(String matched);
    
    /**
     * Batch fetch issues detailed information from server.
     *  
     * @param keys The issue keys need be fetched
     * @return a map of fetched issue data
     * @throws TrackerException
     */
    Map<String, Issue> fetchIssues(Collection<String> keys);
    
    /**
     * Get the issue url pattern which use to hyperlink the issue key, for example, for JIRA issue, 
     * the pattern would be: http://server/browse/$KEY. 
     * Note: always use <b>$KEY</b> as we will use it to replace with the actual issue key.
     * 
     * The server url can be retrieved from the tracker setting. So, for JIRA, this function can be
     * simply implemented like below:
     * <code>
     * public String getIssueUrlPattern() {
     *     JiraSetting setting = JiraSetting.get(); // Retrieve JIRA setting of current configuration
     *     return StringHelper.normalizeUrl(setting.getHost()) + "/browse/$KEY";
     * }
     * </code>
     * 
     * @return the pattern of issue url
     */
    String getIssueUrlPattern();
}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.