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.
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).
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
.
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
https://bitbucket.example.com/projects/TEST/repos/test-repo/commits/5284ad9879d696876a16bdac71694237292fd93a?web.panels
We use a few different methods to store the data we show in the UI.
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.
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
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:
1 2$.ajax(AJS.contextPath() + "/rest/api/1.0/projects", { type: "GET", success: function(data) { //process the returned data }, contentType: "application/json", });
Rate this page: