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

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,768 views 1 5
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