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.
HTH
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is - the web UI...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm up against Gerrit, compared to Gerrit that's just one additional step to get wrong:
Instead of:
git push origin HEAD:refs/for/master
=> done!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
At least you could write a custom script since there’s a REST API. So this is better than nothing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Because opening a browser and clicking a kajillion times is faster than a CLI alias... e_e
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
function bbpr {
local yourOrg
yourOrg=eg
local rootDir
rootDir=$(git rev-parse --show-toplevel | rev | cut -d'/' -f 1 | rev)
local branch
branch=$(git rev-parse --abbrev-ref HEAD)
local ffbin
ffbin='/Applications/Firefox.app/Contents/MacOS/firefox-bin'
$ffbin --new-tab "https://bitbucket.org/${yourOrg}/${rootDir}/pull-requests/new?source=${branch}&t=1"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still no news matching Gerrit w.r.t. ease of use on this?
All I want is:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello!
So did you end up finding anything?
I'm kinda in that same spot right now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sadly, no.
I've moved on to github for lack of out of the box integration with e.g. Google Cloud Build, smee.io and whatnot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have you tried something like this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yeah I was looking for the same...
unfortunately some companies have managers decided to eat up all this Atlassian crap and we have to deal with all this nonsense
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am getting this:
/var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/user_interaction.rb:328: warning: constant ::NIL is deprecated
/var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/user_interaction.rb:328: warning: constant ::Data is deprecated
/var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/user_interaction.rb:328: warning: constant ::TRUE is deprecated
/var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/user_interaction.rb:328: warning: constant ::FALSE is deprecated
/var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/user_interaction.rb:328: warning: constant ::Fixnum is deprecated
/var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/user_interaction.rb:328: warning: constant ::Bignum is deprecated
/var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/user_interaction.rb:328: warning: constant ::TimeoutError is deprecated
Traceback (most recent call last):
11: from /var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/import.rb:10:in `block in <top (required)>'
10: from /var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/delegates.rb:8:in `run!'
9: from /var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/runner.rb:82:in `run!'
8: from /var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/runner.rb:422:in `run_active_command'
7: from /var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/command.rb:155:in `run'
6: from /var/lib/gems/2.5.0/gems/commander-4.1.6/lib/commander/command.rb:180:in `call'
5: from /var/lib/gems/2.5.0/gems/atlassian-stash-0.7.0/bin/stash:142:in `block (2 levels) in <top (required)>'
4: from /var/lib/gems/2.5.0/gems/atlassian-stash-0.7.0/lib/atlassian/stash/git.rb:50:in `ensure_within_git!'
3: from /var/lib/gems/2.5.0/gems/atlassian-stash-0.7.0/bin/stash:144:in `block (3 levels) in <top (required)>'
2: from /var/lib/gems/2.5.0/gems/atlassian-stash-0.7.0/lib/atlassian/stash/pull_request.rb:101:in `create_pull_request'
1: from /usr/lib/ruby/2.5.0/json/common.rb:156:in `parse'
/usr/lib/ruby/2.5.0/json/common.rb:156:in `parse': 765: unexpected token at '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> (JSON::ParserError)
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://bitbucket...">here</a>.</p>
</body></html>
'
Any idea how to resolve it?
BR
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You are calling an URL that redirects to another one for some (hopefully good) reason.
The library you are using is not handling this redirect automatically and you get the response "302 - what you are looking for is not here, but it's there".
So you should either find the option in the library you are using to follow the redirection when it occurs, or you must check first your HTTP response code before processing the HTTP response message.
On HTTP code 302, you should call the new URL.
HTH.
Laurent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
http://stackoverflow.com/a/15046966
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have a broken link: stash is now at https://bitbucket.org/atlassian/bitbucket-server-cli
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
pushd $repo;
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://git@stash.internal:7999/PROJECTNAME/$(basename $(pwd)).git;
popd 2>&1 >/dev/null ;
done
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there any other way we can perform this action without having stash installed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would be keen to find this out. We have 27 repositories which need e.g. their AssemblyInfo.cs updating with the new major version number so would like to automate creating pull requests for all these in one go - the UI takes far too long :/
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jonas may drop the part "command line"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jonas dropped everything but "pull".
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.