The export and import can be done via the REST-API of Bitbucket. The REST-API offers a interface which enables you to get the settings of the hook as JSON. This JSON settings you can store and import again(link)

Example

Description of the examples:

  • com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-merge - Merge-Hook
  • com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-push - Push-Hook
  • PROJECT_1 - The slug of the project in this example
  • rep_1  - The slug of the test repository in  this example
  • admin:admin - username and password to access the settings via REST-API
  • http://bitbucket:7990/bitbucket - The URL of the Bitbucket instance

How to get the existing settings

This example shows how to get the settings of the repository "rep_1" in the project "PROJECT_1" via the tool curl from the hook key "com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-push"


curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://admin:admin@bitbucket:7990/bitbucket/rest/api/1.0/projects/PROJECT_1/repos/rep_1/settings/hooks/com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-merge/settings
BASH


The result:

{"mergeTextSyntaxCheckRegEx":"","mergeTextSyntaxCheckMessage":"","mergeCheckIssueStatusCheckEnabled":true,"mergeTextIssueStatusCheckRegEx":"To Do|Done|Fertig|Aufgaben","mergeTextIssueStatusCheckMessage":"","mergeCheckIssueKeyNeeded":true,"mergeCheckIssueKeyRegEx":"","mergeTextJQLQuery":"","mergeTextJQLQueryMessage":"","mergeTextBranchCheckRegEx":"","mergeCheckExceptionGroupEnabled":true,"mergeTextExceptionGroup":"admin"}
CODE

How to put the JSON Settings back to the hook

The settings will be put back to the repository "rep_1" in the project "PROJECT_1" via the tool curl. 

curl -H 'Content-Type: application/json' -X PUT -d '{"mergeTextSyntaxCheckRegEx":"","mergeTextSyntaxCheckMessage":"","mergeCheckIssueStatusCheckEnabled":true,"mergeTextIssueStatusCheckRegEx":"To Do|Done|Fertig|Aufgaben","mergeTextIssueStatusCheckMessage":"","mergeCheckIssueKeyNeeded":true,"mergeCheckIssueKeyRegEx":"","mergeTextJQLQuery":"","mergeTextJQLQueryMessage":"","mergeTextBranchCheckRegEx":"","mergeCheckExceptionGroupEnabled":true,"mergeTextExceptionGroup":"admin"}' http://admin:admin@bitbucket:7990/bitbucket/rest/api/1.0/projects/PROJECT_1/repos/rep_1/settings/hooks/com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-merge/settings 
BASH