How to figure out if a branch was deleted on merge in Bitbucket Server
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Sometimes, there might be a need to check and confirm if a branch was deleted on the merge especially when the DEBUG logging is NOT enabled
Environment
Bitbucket Server 7.6.
The audit logging events can change in future releases and this KB might not be applicable there
Solution
The branch delete events can be captured when the branch is deleted as part of a Pull Request Merge. This is possible after setting the "END_USER_ACTIVITY" in the audit logs to "Full". The multiple coverage areas available in audit logs can be seen here.
Once it is set to FULL, the following can be seen in the audit logs when the branch is deleted as part of a Pull Request Merge (pullrequestmerged event).
Merge:
1
{"affectedObjects":[{"id":"32:1","name":"PR#1","type":"PULL_REQUEST"},{"id":"32","name":"tda","type":"REPOSITORY"},{"id":"1","name":"TEST","type":"PROJECT"}],"auditType":{"action":"Pull request merged","actionI18nKey":"bitbucket.service.pullrequest.audit.action.pullrequestmerged","area":"END_USER_ACTIVITY","category":"Pull requests","categoryI18nKey":"bitbucket.service.audit.category.pullrequests","level":"BASE"},"author":{"id":"1","name":"tahir.bhat","type":"NORMAL"},"changedValues":[],"extraAttributes":[{"name":"From ref","nameI18nKey":"bitbucket.service.pullrequest.audit.attribute.pullrequest.fromref","value":"test-branch"},{"name":"Merge commit","nameI18nKey":"bitbucket.service.pullrequest.audit.attribute.pullrequestmerged.mergecommit","value":"8b8790ddf43"},{"name":"details","nameI18nKey":"bitbucket.audit.attribute.legacy.details","value":"{\"id\":1,\"changes\":[{\"ref\":\"refs/heads/master\",\"from\":\"e7397bf86dd22f450d1b0572395cf32e3664de57\",\"to\":\"8b8790ddf43d3b6d540f05d474de9593ccc69ec4\"}]}"},{"name":"target","nameI18nKey":"bitbucket.audit.attribute.legacy.target","value":"TEST/tda"},{"name":"To ref","nameI18nKey":"bitbucket.service.pullrequest.audit.attribute.pullrequest.toref","value":"master"},{"name":"Commit message","nameI18nKey":"bitbucket.service.pullrequest.audit.attribute.pullrequestmerged.message","value":"Pull request #1: Test branch\n\nMerge in TEST/tda from test-branch to master"}],"method":"Browser","node":"25084e08-831c-4535-b331-641925ffd99d","source":"172.17.0.1","system":"http://localhost:7992","timestamp":{"epochSecond":1634139007,"nano":441000000},"version":"1.0"}
Branch deletion:
1
{"affectedObjects":[{"id":"32:1","name":"PR#1","type":"PULL_REQUEST"},{"id":"32","name":"tda","type":"REPOSITORY"},{"id":"1","name":"TEST","type":"PROJECT"}],"auditType":{"action":"Pull request merged","actionI18nKey":"bitbucket.service.pullrequest.audit.action.pullrequestmerged","area":"END_USER_ACTIVITY","category":"Pull requests","categoryI18nKey":"bitbucket.service.audit.category.pullrequests","level":"BASE"},"author":{"id":"1","name":"tahir.bhat","type":"NORMAL"},"changedValues":[],"extraAttributes":[{"name":"From ref","nameI18nKey":"bitbucket.service.pullrequest.audit.attribute.pullrequest.fromref","value":"test-branch"},{"name":"Merge commit","nameI18nKey":"bitbucket.service.pullrequest.audit.attribute.pullrequestmerged.mergecommit","value":"8b8790ddf43"},{"name":"details","nameI18nKey":"bitbucket.audit.attribute.legacy.details","value":"{\"id\":1,\"changes\":[{\"ref\":\"refs/heads/master\",\"from\":\"e7397bf86dd22f450d1b0572395cf32e3664de57\",\"to\":\"8b8790ddf43d3b6d540f05d474de9593ccc69ec4\"}]}"}
Was this helpful?