Skip to content

Instantly share code, notes, and snippets.

@casualjim
Created August 19, 2011 17:02
Show Gist options
  • Select an option

  • Save casualjim/1157353 to your computer and use it in GitHub Desktop.

Select an option

Save casualjim/1157353 to your computer and use it in GitHub Desktop.
# Upstart file for sinatra github hook
start on runlevel [2345]
stop on runlevel [06]
#console logged
#respawn
env RUBYOPT=rubygems
exec ruby /home/ivan/src/github_post_receive/hook_server.rb
require 'sinatra'
require 'net/http'
require 'yajl/json_gem'
configure do
set :port, 4480
end
get "/" do
puts "works"
"works"
end
post "/:project" do
Net::HTTP.start("localhost", 8080) { |http|
project = params[:project]
puts "Triggerng build for #{project}"
req = Net::HTTP::Get.new("/job/#{project}/build?token=GITHUB&cause=Updated%20from%20github")
req.basic_auth 'notifier', 'PASSWORD'
puts http.request(req)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment