Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
I just tried out Hudson/Jenkins. This is a little more powerful, but does what I need. –  queueoverflow Oct 12 '11 at 15:56

1 Answer 1

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)

share|improve this answer
    
That sounds way easier than the whole Jenkins. I'll give it a try in the next days. –  queueoverflow Oct 12 '11 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. –  queueoverflow Oct 13 '11 at 9:08
    
@queueoverflow: Make sure the permissions are right (i.e. which user is the hook called as?), and the working directory fits. –  Paŭlo Ebermann Oct 13 '11 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.