Reputation: 2316
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?
Upvotes: 5
Views: 555
Reputation: 343
Consider integrating http://jenkins-ci.org/ to your workflow, to take care of the build process, using a "git post-receive hook" to trigger the build as (suggested by @VonC).
If you want to use the "Forking Workflow" as suggested by @flup, you can take a look to http://gitlab.com which provides an easy way to manage pull/merge requests, fork repositories and to add hooks.
Upvotes: 2
Reputation: 27104
You could switch to a forking Workflow, where each developer in the company has a personal public bare repo, which is a fork of the official central repository.
Then, when you want to build your changes, you push them to (a branch or the master of) your own personal public repo.
The build server not only clones the official central repository, but also your public repo. So when you push to your personal public repo, the build server merges the changes and does a personal build for you. Just like it probably already does for the official central repository?
Note that this is not too different from @VonC s answer, just focusses a bit more on the workflow. The personal public repo may well be on the build server, like @VonC suggests. Or it could be somewhere else. As long as it's some place public enough that the build server and you and your colleagues can find it.
Upvotes: 2
Reputation: 1323963
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.
Upvotes: 4