Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Creating stash pull request programmatically

Vikas Dogra January 29, 2013

I want to create a pull request automatically once a new branch is added to a project. My script will take a reviewer's name and branch name and will create a branch on stash repository using git command. Is there a way for me to create a pull request through my script?Is there a stash client in similar lines as jira client? Or can it be done using stash RestAPI or Java API?

2 answers

0 votes
Stefan Saasen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 29, 2013

Hi Vikas,

You might be interested in http://blogs.atlassian.com/2012/11/stash-pull-requests-from-the-command-line/


Cheers,

Stefan

Vikas Dogra January 30, 2013

Thanks Stefan, I will try this. This was exactly what i was looking for.

0 votes
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2013

Hi Vikas,

Personally I would do this as a Stash plugin. Here is an example of a plugin that acts as a webhook to notify a Jenkins URL:

https://bitbucket.org/atlassian/stash-webhook-plugin

The most important class:

https://bitbucket.org/atlassian/stash-webhook-plugin/src/master/src/main/java/com/atlassian/stash/plugin/webook/WebHook.java?at=master

In Stash 2.0+ the RepositoryPushEvent has access to the RefChanges, which have a 'type' which might be ADD. For those refs you could create a PullRequest by injecting the PullRequestService and calling create.

You could also do this via REST, but then you will need a script to poll Stash for new changes.

https://developer.atlassian.com/static/rest/stash/latest/stash-rest.html#id237698

I hope this helps.

Charles

Vikas Dogra January 30, 2013

Thanks Charles, Your first two links are not working but i got the idea. I will try the command line interface suggested by Stefan and see if it does everything which we require.

Is it possible for you to update the broken links?

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

Hi Vikas,

Sorry about that. I migrated that repository to our Atlassian account. They should work now.

Charles

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events