Git Build : The script that make obsolete your Continuous Integration!

(or the unbreakable build!)

The goal of ‘git build’ script is to run a command which determine if a commit is good before pushing your commits on the remote.
It could easily configured to build your project and run the unit tests automaticaly in a private build and then assure you that your git history contains only good commits.

Principle

The different steps of the script are the following :

1. Clone the current git repository in a temporary folder
2. Rebase on upstream modifications
3. Run a custom command (build, unit tests,…)
4. Push commits only if the custom command succeed
5. Give a feedback of the build by a notification

Installation

1. Copy the git-build script in a directory that is in your path (or add the directory to your path) keeping the file name ‘git-build’.
2. Copy the 2 files git-build_success.png and git-build_fail.png in the same directory keeping the names “git-build_success.png” and “git-build_fail.png”.
3. If you are under windows, install Growl and add growl folder to the path.

Configuration

For each new git repository you use and only one time, set the command that will be run before pushing.

Example using maven :

git config private-build.command "mvn clean install"

Example using msbuild :

git config private-build.command "msbuild my.build /t:UnitTests /p:Configuration:Debug"

Use

Each time you want to push, instead, call the command :

git build

Advantages

The advantages of such a solution are :

Philippe Miossec 24 March 2013
blog comments powered by Disqus