Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I build my local git repo on external server?

In our company we have really powerful linux based build servers (double Xeon with 40 core) and not so powerful win7 laptops. We building our product in C/C++ language for an esoteric CPU. The compiler only exist in Linux. I can edit my git repo with Qt Creator. It is working and quite fast and everything. But I can't build the source on our Laptop. We have a main git repo and I can clone the same repo to my laptop and to our build server. I want to achieve that when I press the build button my code magically building on build server. I did a proof of concept solution where my build script do a git diff on my repo and scp it to the build server than it ssh to build server apply that diff on the server repo than start and wait the compilation. But that solution is not so fool proof. I think a better approaching/method is exist. So how can I build my git repo on external server?

like image 555
Industrial-antidepressant Avatar asked Mar 12 '15 20:03

Industrial-antidepressant


1 Answers

If you can push to a bare repo on the build server, then you can associate to that bare repo a post-receive hook (.git/hooks/post-receive) which will:

  • checkout the code

    #!/bin/sh
    git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f
    
  • trigger the compilation.

That way, you don't have to handle the diff yourself.
You only have to associate to the build button the action to push your branch to the bare repo of the build server, and the post-receive hook will do the rest.

like image 75
VonC Avatar answered Oct 01 '22 00:10

VonC