How do I get the branch name and last commit date using a groovy script?
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.
Thanks,
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.
Regards,
Yogesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Yogesh Mude ,
If you look at this Community post (https://community.atlassian.com/t5/Adaptavist-questions/Scriptrunner-list-of-tags/qaq-p/1376193) it has a Script on it, that reports on all tags belonging to a repository using the
com.atlassian.bitbucket.repository.RefService.getTags()
method.
You could use that Script as a basis, but instead you would want to use the
com.atlassian.bitbucket.repository.RefService.getBranches()
method. The results of which contain the last commit.
Here is the JavaDoc with the details of RefService: https://docs.atlassian.com/bitbucket-server/javadoc/6.9.0/api/com/atlassian/bitbucket/repository/RefService.html
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: https://docs.atlassian.com/bitbucket-server/javadoc/6.9.0/api/com/atlassian/bitbucket/pull/PullRequestService.html
Please let me know if you require any more help?
Kind regards,
Robert Giddings,
Product Manager, ScriptRunner for Bitbucket
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.