Looking at the REST API documentation setting close_source_branch:true should delete the source branch after a Pull request has been merged.
I create a new branch with changes:
curl -sk -X POST -u 'user:pass' --url 'https://api.bitbucket.org/2.0/repositories/alconpc/cdit-dnr-test-1/src' -F "message=testing rest $(date) [skip ci]" -F 'branch=feature/rest-test' -F 'parents=develop' -F '/documents/config-file-one.yml=@a' -F '/documents/config-file-new.yml=@a'
I validate this works on the BB GUI, next I create the PR:
curl -sk -X POST -u 'user:pass' --url 'https://api.bitbucket.org/2.0/repositories/alconpc/cdit-dnr-test-1/pullrequests' -H 'Content-Type: application/json' --data '{"close_source_branch":true,"description":"automated process to update config files via REST","destination":{"branch":{"name":"develop"}},"source":{"branch":{"name":"feature/rest-test"}},"title":"Update config files date","type": "pullrequest"}' | jq .
{
"rendered": {
"description": {............
I also verify that the PR was created with the delete branch option
curl -sk -X GET -u 'user:pass' --url 'https://api.bitbucket.org/2.0/repositories/alconpc/cdit-dnr-test-1/pullrequests/7' | jq .close_source_branch
true
So I expect that when I merge the PR it will delete feature/rest-test
curl -sk -X POST -u 'user:pass' --url 'https://api.bitbucket.org/2.0/repositories/alconpc/cdit-dnr-test-1/pullrequests/7/merge' | jq .
{
"rendered": {
"description": {
However it is not deleted :(
I am not sure what I am doing incorrectly so that it is not deleting.
I have also tried adding the close_source_branch to the merge:
curl -ski -X POST -u 'user:pass' --url 'https://api.bitbucket.org/2.0/repositories/alconpc/cdit-dnr-test-1/pullrequests/3/merge' --data '{"close_source_branch":true,"type":"pullrequest"}'
and it does not help.
The above does work if you remember to include
Content-Type: application/json
in the headers ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.