Last updated May 7, 2024

Adding commit metadata

Bitbucket Data Center provides a number of places plugins can display extra information about a commit, in fact we do precisely that with Jira integration and build status.

Adding to the UI

Bitbucket Data Center adds commit metadata in a few places, the commits list (viewable in pull requests and general repository browsing) and commits (usually navigated to by clicking a commit hashed id link).

Commits list

For both Jira integration and build status we conditionally add a column to the commits list in Bitbucket Data Center. Plugins can do the same by adding a web section for the column to bitbucket.commits.extras.

Commit view

Bitbucket Data Center allows you to extend the commit page using a web panel extension point. We do this ourselves for the Jira integration using the bitbucket.commit.related-entities extension point. You take a look at the extension points available for yourself by navigating to a commit and appending ?web.panels to the URL for example

Storing metadata

We use a few different methods to store the data we show in the UI.

Commit Indexer

The commit indexer manages whether you have seen a commit before and provides a way of storing a small amount of data against a commit. Bitbucket Data Center's Jira integration uses the commit indexer to be notified of new commits then extract and store Jira issue keys from the commit messages.

General Data Storage

We usually use Active Objects to store data in plugins, for example in the build status plugin. It is also possible to store simple key-value data in the plugin settings service example

Accessing your data in the UI

There are a few methods to access data from the server, Bitbucket Data Center's Jira integration plugin uses a context provider to supply data from the commit index which is used in its soy template.

Our build status plugin uses its own REST endpoint to fetch data on page load. You can create your own REST plugin module to expose services and data entities as REST APIs. You can use AJAX via jQuery to call your own REST endpoint, there's really not much to it:

$.ajax(AJS.contextPath() + "/rest/api/1.0/projects", {
        type: "GET",
        success: function(data) {
            //process the returned data
        contentType: "application/json",

Rate this page: