If you want to create a Pull Request from the command line, you can use the REST API :
curl -s -u USER:PASSWD -X POST -H 'Content-Type: application/json' -d 'JSON_struct_with_data' http://SERVER:PORT/rest/api/1.0/projects/PRJKEY/repos/REPONAME/pull-requests
Check the doc of REST API for the details on the JSON data block.
Ouch! I get a lot of groans about the the arcane Gerrit syntax (git push origin HEAD:refs/for/MAIN) and the above is not an improvement.
I was hoping that there was something no more complicated in terms of syntax, configurations, required tools to be installed, passwords, etc. than Gerrit for creating a Bitbucket pull requests.
I can't see anything in that link that shows me how to create a pull request from the command line. I have created pull requests in the Bitbucket web-interface, I've downloaded pull requests from the command line, but I've never found a way to create pull requests from the command line.
The best option is probably to use a couple different tools developed for Stash and/or BItBucket Cloud to do this. The REST API should be similar between them (even though their codebases aren't necessarily the same).
See the excellent utilities I came across from this StackOverflow answer.
the Attlassian team have stash (ruby): https://bitbucket.org/atlassian/stash-command-line-tools
Zhemao has bitbucket-cli (python): https://bitbucket.org/zhemao/bitbucket-cli
Good spot. It is also easy to install them via `gem install atlassian-stash`. Once you've run `stash configure` you can easily operate on a large number of repos in a loop if you are dealing with a massive find/replace for example.
Sadly it only operates on https remote-url configured repos even though it should be able to map ssh:// or git repos to the SSH counterpart since the `stash configure` requires the web URL and the repo URL should largely match.
Given a local folder like PROJECTNAME if you are updating a duplicated entry across multiple repositories you can `cd PROJECTNAME` and then run the script below (assuming you setup the `git create-pull-request` alias.
for repo in `ls -A`; do
git remote set-url origin https://stash.internal:8444/scm/PROJECTNAME/$(basename $(pwd)).git ;
git create-pull-request branches/JIRA-123 master @reviewer1 @reviewer2 ;
git remote set-url origin ssh://firstname.lastname@example.org:7999/PROJECTNAME/$(basename $(pwd)).git;
popd 2>&1 >/dev/null ;
Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs