Committing CIJoe Runner Configuration into Git

Back | cijoe, git, linux, build | 8/31/2011 |

A nice way of telling CIJoe (or any other CI service) what to do is to commit git configuration under, for example, git-config.

Here’s what a typical git-config/config looks like. It’s the same as your usual .git/config.

We’re going to have a remote [origin] and a [cijoe] section that tells CIJoe what to do.

  1. [remote "origin"]
  2.     fetch = +refs/heads/*:refs/remotes/origin/*
  3.     url = git@github.com:name/project.git
  4. [branch "master"]
  5.     remote = origin
  6.     merge = refs/heads/master
  7. [cijoe]
  8.     runner = ((bundle check || bundle install) && bundle exec spec spec )
  9.     buildqueue = true

We can also have two scripts, git-config/build-worked and git-config/build-failed. Here’s the latter.

  1. #!/bin/sh
  2. echo "
  3. Visit http://ci.example.com:9000/ for details
  4.  
  5. Author:  $AUTHOR
  6. Message:
  7. $MESSAGE
  8.  
  9. $OUTPUT
  10. " | mail -s "[example] BUILD FAILED $SHA" --to dev@example.com

How do we hook this up? CIJoe tells us to place all this stuff into .git/hooks.

We can just trick it with some symbolic links on the CI server.

  1. cd .git
  2. rm config
  3. ln -s ../git-config/config .
  4. cd hooks
  5. ln -s ../../git-config/build-failed .
  6. ln -s ../../git-config/build-worked .

Easy.