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

Get branch details

How do I get the branch name and last commit date using a groovy script?

1 answer

Hi @Yogesh Mude ,

Please can you tell me how you are using this groovy script?

Is it as a Pre Hook or Merge Check, for example? Or a script you want to run in the Console?

I ask, because knowing where and how the script will be run will affect the script example I can provide you.


Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Hello, @Robert Giddings _Adaptavist_ ,

Thanks for the time and response.

Actually, we have a requirement like every Friday or once in a week bitbucket should send an email listing all open branches.

So for this, I checked in Script Runner there is a Jobs (ie. Schedule Custom Email) using which I can send an email based on the interval.

So here I need to write a script where I can get all detail like Project Name, Open branch Name,  Last commit date, Has open pull request or not, etc..

Can you guide me or provide me any previous script for assistance.



Hi @Yogesh Mude ,

If you look at this Community post ( it has a Script on it, that reports on all tags belonging to a repository using the 



You could use that Script as a basis, but instead you would want to use the 


method. The results of which contain the last commit.

Here is the JavaDoc with the details of RefService:

Also, you will also want to use the PullRequestService in order to search for open Pull Requests.

Here is the JavaDoc with the details of the PullRequestService:

Please let me know if you require any more help?

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

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,920 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