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

Can I run and check the output of a git hook in a merge check script?



I am trying to set up a merge check script that will reuse an existing pre-commit git hook in my repository(from the ".git/hooks" folder) and if the hook returns the ok status I will allow the merge.

From my understanding the ".git/hooks" folder is only local so I will upload the hook somewhere in the repo if that is needed.


My main goal is to check if that hook returns OK when someone is trying to merge into the main branch because that will be easier for newcomers that do not have the hook setup locally.

Also some way of checking the hook on the server side when they are pushing would help.


Is there any way to achieve this behavior using Scriptrunner or maybe other basic git functionalities?

Thank you!

1 answer

1 accepted

Hi @Ionut Eduard Oprescu ,

Firstly I'd like to clarify if you are using Bitbucket Cloud or Bitbucket Server/DC?

I ask, because the tags for this Community question are for both Bitbucket Cloud and ScriptRunner. However ScriptRunner is currently only compatible with Bitbucket Server/DC.

If you are using Bitbucket Server/DC, then the ScriptRunner for Bitbucket team would first recommend you try and rewrite your local pre-hook as either a server-side custom pre-hook or merge-check using ScriptRunner.

The documentation for a custom pre-hook can be found here:

And the documentation for a custom merge-check can be found here:

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket


I do have ScriptRunner in my repository settings so using the pre-hook or merge-check is the way to go, but at the same time I am looking for a way to reuse my existing local hooks in those scripts.

Maybe that could be a good addition to ScriptRunner functionalities.

Thank you for your answer!

@Ionut Eduard Oprescu ,

Thank you for your answer.

I'm guessing that currently the issue is that your local hooks are written in a language other than Groovy? And hence require re-writing for ScriptRunner.

It is something we will consider. But for now is not something we currently support.

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

That is the case, my scripts are in bash/sh.

I marked the question as answered since I got the info I needed.

Thank you for your replies!

Suggest an answer

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

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,440 views 4 7
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