Missed Team ’24? Catch up on announcements here.

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

Git Automated Setup

MarkL June 15, 2013

I want to set up Git so that when I commit to BitBucket my web server automatically fetches those commits and updates the files on the webserver.

How can I do that?

2 answers

1 accepted

1 vote
Answer accepted
twong_atlassian
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.
June 16, 2013

AFAIK, BB doesn't allow you to set up your own post-receive hooks, though I admit I haven't really looked into it much.

I'd cheat.

Set up a cron job on your webserver that simply git checkout -f's every 5 mins, on a branch. Whenever you want to update your webserver, push to that branch.

You can get fancier if you'd like.

You can write a client side script that wraps the git git pushing operation, then does something like ssh user@yourwebserver ./script-that-handles-pulling-down-stuff-then-restarting-web-server.sh EDIT- READ MY EDIT BELOW

Hoping Marcus Bertrand doesn't come and rip me a new one for telling people to poll BB servers (ducks).

EDIT

Marcus cleverly (with great prejudice) informed me that there is a post commit POST service and I shouldn't tell people to poll our servers.

https://confluence.atlassian.com/display/BITBUCKET/POST+Service+Management

So you could simply create a webservice on your web server that listens for a post to some url, then triggers a small script that does the checkout -f. If you wanna be really really nice to our servers, you could parse the resultant message that we send to your service and only do the checkout if it affects your branch.

Please be nice to our servers :)

0 votes
Dylan Barlett August 30, 2013

See https://gist.github.com/oodavid/1809044 - works like a charm.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events