A repository merge check module defines a Java component that can veto a request by a user to merge a pull request. A vetoed pull request will be prevented from merging and feedback is given to the user explaining why the merge can't proceed.
Example merge checks might include:
Note: although merge checks restrict the merge operation within Bitbucket Data Center, they do not prevent users from merging branches in their local clones and pushing this change. Please look at branch permissions for this functionality.
Please see the how-to guide for more information on creating a repository merge check.
The root element for the Repository Merge Check plugin module is <repository-merge-check/>
. It allows the following
attributes for configuration:
Name | Required | Description | Default |
---|---|---|---|
key | Yes | The identifier of the plugin module. This key must be unique within the plugin where it is defined. | N/A |
class | Yes | The fully qualified Java class name of the merge check. This class must implement RepositoryMergeCheck. | N/A |
name | Yes | The human-readable name of the plugin module. | N/A |
i18n-name-key | The i18n key of the human-readable name of the plugin module. If defined, this name will be displayed in the Repository Settings > Hooks section instead of the value provided in the 'name' attribute | N/A | |
configurable | Whether the merge check can be enabled or disabled at the repository level. If set to false, the merge check will enabled for all repositories and will not be displayed in the Repository Settings > Hooks section. | true |
Name | Required | Description | Default |
---|---|---|---|
description | The description of the plugin module. The 'key' attribute can be specified to declare a localisation key for the value instead of text in the element body. | N/A | |
icon | Repository merge checks are able to display a customised icon on the administration screen. Regardless of the original size, this icon will be scaled to 48x48 px. | N/A | |
config-form | Repository merge checks are able to have additional per-repository settings that are automatically passed to your merge check. Configuration form modules are used to describe a simple configuration form that will be automatically saved, loaded and validated. See below for more details. | N/A | |
validator |
The class of the validation component that will perform setting validation before save.
This class must implement com.atlassian.bitbucket.setting.RepositorySettingsValidator .
Alternatively this interface can be applied on the merge check instead, and this element can be ignored.
| N/A |
These are the elements required for the config-form
element.
Name | Required | Description | Default |
---|---|---|---|
directory | Yes | A directory that contains any custom Soy, JavaScript and CSS files required to implement the view. | N/A |
view | Yes |
A JavaScript function that will be invoked to display the form. This function will be expected to return
HTML which may be generated via Soy or some other mechanism, ideally using AUI for consistency.
For more information about AUI please visit the sandbox. For an a list of available Soy templates that you can use in your own configuration form, consult the source. | N/A |
Here is an example atlassian-plugin.xml
file containing just a repository merge check. The merge check in this
example is enabled for all repositories (because of configurable="false").
1 2<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> </plugin-info> <!-- add our i18n resource --> <resource type="i18n" name="i18n" location="is-admin-merge-check"/> <repository-merge-check key="isAdmin" class="bean:isAdminMergeCheck" configurable="false"/> </atlassian-plugin>
Here is an example atlassian-plugin.xml
file containing a repository merge check and an configuration form that is
validated.
1 2<atlassian-plugin name="My Repository Merge Check Example" key="example.plugin.mymergecheck" plugins-version="2"> <plugin-info> <description>A basic merge check plugin</description> <vendor name="My Company" url="http://www.mycompany.com"/> <version>1.0</version> </plugin-info> <repository-merge-check key="exampleMergeCheck" name="Requires Green Build" class="com.mycompany.example.plugin.mymergecheck.MyRepositoryMergeCheck"> <!-- Optional --> <icon>icons/greenbuild.png</icon> <!-- Optional --> <config-form name="Simple Config" key="simpleMergeCheck-config"> <view>bitbucket.config.example.mergecheck.simple</view> <directory location="/static/"/> </config-form> <!-- Optional --> <validator>com.mycompany.example.plugin.mymergecheck.MyValidator</validator> </repository-merge-check> </atlassian-plugin>
You can find some concrete examples on the how-to guide and the Controlling when pull requests can be merged tutorial.
Rate this page: