Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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?

Hello,

 

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: https://docs.adaptavist.com/sr4bib/6.25.0/features/script-pre-receive-hooks/custom-pre-receive-hooks

And the documentation for a custom merge-check can be found here: https://docs.adaptavist.com/sr4bib/6.24.0/features/script-merge-checks/custom-merge-check

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Hello,

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
TAGS
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

855 views 16 11
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