Due to a refactoring in from the major release 3.x to the major release 4.x, the merge hook got a new hook key: com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-merge. This is the reason, why Bitbucket can not find the already configured 3.x settings in the 4.x merge hook. But the hook settings are still available. This article describes how to migrate the settings of the merge hook.


The migration can be done via the REST-API of Bitbucket. The REST-API offers a interface which enables you to get the settings of the old hook as JSON. This JSON settings you can push back to the new hook. (link)

Example

Description of the examples:

  • com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key - Old hook key
  • com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-merge - New hook key
  • 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 3.x settings

This example shows how to get the 3.x 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"


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/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 4.x hook

This example shows how to put the 3.x settings to the 4.x hook. The settings will be put to the repository "rep_1" in the project "PROJECT_1" via the tool curl. Note: See the different hook key ending  "com.lb.software.stash.jira.connector.lb-software-stash-jira-connector:lb-software-stash-jira-connector-issue-key-merge"


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


How to put the JSON Settings back to the 4.x hook and enable the hook

If you plan to enable the hook you just need to use a different URL use enabled instead of settings.


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/enabled
BASH