post-receive hook to auto push the latest commit

Hi

I was going through http://toroid.org/ams/git-website-howtoto learn how to add post-receive hook to automatically push the changes to live repo instead of doing git pull everytime. git pull also changes the owner of file to the user who is doing pull. our project directory is setup as follows.

chown -R wwwrun:developer project/

After pushing to bare repo we do pull to server root dirctory project/. This changes the ownership of file to username. With post-recieve hook the username will remain git. It is easy to change the user under which apache run so I can change that to git:developer. It will make life much easier and probabaly we wil lnever run into permission error as it happened in the past.

When I trie to edit post-recieve hook in stash-home repositiries I saw following message in post-recieve file

#!/usr/bin/env bash
#>*******************************************************
# THIS FILE WAS AUTO-GENERATED BY ATLASSIAN STASH.
# DO NOT MODIFY UNDER ANY CIRCUMSTANCE.
#>*******************************************************
if [[ "$OSTYPE" == "cygwin" ]]; then
    exec $(cygpath $STASH_HOOK_COORDINATOR) hooks/post-receive.d "$@" <&0 >&1 2>&2
else
    exec $STASH_HOOK_COORDINATOR hooks/post-receive.d "$@" <&0 >&1 2>&2
fi

Where am I suppose to add post-recieve hook then? Can I create new file with any name and add hook code from above link? I am asuming stash go through post-receive.d directory for hook files.

Thanks

Raminder

1 answer

1 accepted

0 votes
Accepted answer

Hi Raminder,

You can add your own custom hooks to the pre-recieve.d and post-receive.d directories, and our scripts will execute them (in order).

Definitely don't modify those scripts - Stash depends on our own hooks to be notified of changes during a push. :)

Cheers,

Charles

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

436 views 6 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you