2

I have a LaTeX project in git, there is a makefile. So basically a server would have to do this:

git checkout master
make > logfile 2>&1

Given that I push into a repo on the server.

I could do this with a cron job, but it seems kind of missing the point. Is there some way to initiate this after I pushed via SSH?

1
  • I just tried out Hudson/Jenkins. This is a little more powerful, but does what I need. Oct 12, 2011 at 15:56

1 Answer 1

3

You can do this in native git with a post-receive hook. Since you shouldn't be pushing to a non-bare repo, you'll need a script along the lines of this

#!/bin/sh
target="/tmp/math"
exec > "$target/$(date +%s)_$(uuidgen).log" 2>&1
mkdir -p "$target"
GIT_WORK_TREE="$target" git checkout -f
cd "$target"
make

Put that in hooks/post-receive inside the bare repo, and you should be all set (note that this will not create $TARGET_DIR, you'll have to do that manually)

3
  • That sounds way easier than the whole Jenkins. I'll give it a try in the next days. Oct 12, 2011 at 18:46
  • I created the hook, but it is not executed when I push. If I call .git/hooks/post-reveive manually on the server, it works though. Oct 13, 2011 at 9:08
  • @queueoverflow: Make sure the permissions are right (i.e. which user is the hook called as?), and the working directory fits. Oct 13, 2011 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .