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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get a list of all commits from a push on a pre-receive hook using Bitbucket SPI API?



We have an idea of creating a pre-receive hook handler using ScritpRunner, which would only allow a push (containing some specific entries in any commit), if there is a special entry in one of the commit messages within this push request.

With PreRepositoryHookCommitCallback I can read the changes content and a commit message, but only from within the current commit. Is there a way to access other commits from a specific push?


Here is a pseudocode of what we try to accomplish:

commitCallback =
new PreRepositoryHookCommitCallback() {

boolean onCommitAdded(@Nonnull CommitAddedDetails commitDetails) {

if (commit.refChanges.any( contains a string matching a pattern) && !allPushCommits.any( has a message containing a special entry) ){
resultBuilder.veto("not allowed")
return false

1 answer

1 accepted

Hi @Tomasz_Kmiecik ,

As a first suggestion I would try storing the commits (or just the commit messages, if that is what you are interested in) inside a global list.

Then call the onEnd() method to process the list.

For details see the JavaDoc for PreRepositoryHookCommitCallback here:

And it's parent class here:

Please let me know if this helps?


Robert Giddings,

Product Manager, Adaptavist

Hi @Robert Giddings _Adaptavist_ 
Thanks a lot for this suggestion. onEnd() method did the trick.

Kind regards,
Tomasz Kmiecik

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,755 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you