Skip to content

Instantly share code, notes, and snippets.

@padwasabimasala
Created May 28, 2014 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save padwasabimasala/603e9e92f977f18abbc0 to your computer and use it in GitHub Desktop.
Save padwasabimasala/603e9e92f977f18abbc0 to your computer and use it in GitHub Desktop.
Git Post Commit Hook to build JRuby Rails App
#!/bin/bash
export PATH='/home/git/jruby-1.7.11/bin':$PATH
webapps=/opt/tomcat_ruby/webapps
base=/home/git/passport
repo=$base/passport.git
latest_commit=$(cd $repo && git log --pretty=oneline -n1 |cut -d' ' -f1)
build_dir=$base/builds/$latest_commit
function run {
echo Running -- "$@"
eval "$@"
status=$?
if test $status -ne 0; then
echo "Error! exit status was $status for command \"$@\""
exit 1
fi
}
echo "Building commit $latest_commit started at $(date)"
if test -d "$build_dir"; then
echo Warning: build directory $build_dir already exists. This is likely the result of a failed build.
run rm -Rf $build_dir
fi
run git clone $repo $build_dir
run cd $build_dir
run bundle
run bundle exec warble
run bundle exec rake test:build
run mv $latest_commit.war passport.war
run cp passport.war $webapps
echo build $latest_commit finished at $(date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment