Skip to content

Instantly share code, notes, and snippets.

@dustin
Created July 15, 2009 23:23
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 dustin/148055 to your computer and use it in GitHub Desktop.
Save dustin/148055 to your computer and use it in GitHub Desktop.
My post-receive hook.
#!/usr/bin/env ruby1.8
require 'rubygems'
require 'sinatra'
require 'json'
base_repo_path = "/home/buildbot/repos"
post '/' do
push = JSON.parse(params[:payload])
branch = push['ref']
old = push['before']
new = push['after']
repo = push['repository']['name']
repo_path = "#{base_repo_path}/#{repo}.git"
system("git --git-dir #{repo_path} remote update")
cmd = "/home/buildbot/bin/git_buildbot.py -c #{repo} -l /tmp/bb.log"
IO.popen("env GIT_DIR=#{repo_path} #{cmd}", "w") do |p|
p.write "#{old} #{new} #{branch}\n"
end
"I got a push to: #{branch} from #{old} to #{new}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment