Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

post-receive hook to auto push the latest commit

codepress September 26, 2013

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
Answer accepted
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2013

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
TAGS
AUG Leaders

Atlassian Community Events