Created
December 16, 2010 23:37
-
-
Save schacon/744223 to your computer and use it in GitHub Desktop.
cijoe hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cijoe hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(dirname $0)/report-build bad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(dirname $0)/report-build good |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "json" | |
require "uri" | |
require "net/http" | |
require 'pp' | |
class Hawk | |
def self.post(status) | |
puts "POST" | |
message = ENV['MESSAGE'] | |
author = ENV['AUTHOR'] | |
sha = ENV['SHA'] | |
out = ENV['OUTPUT'] | |
config = Hawk.config | |
data = { | |
"agent" => config[:agent], | |
"description" => config[:description], | |
"branch" => "master", | |
"author" => author, | |
"sha" => sha, | |
"status" => status, | |
"url" => config[:url], | |
"message" => message, | |
"output" => out | |
} | |
pp data | |
self.post_update(data.to_json) # POST JSON TO URL | |
puts | |
end | |
def self.config | |
return @config if @config | |
c = {} | |
config = `git config --list` | |
config.split("\n").each do |line| | |
k, v = line.split('=') | |
c[k] = v | |
end | |
url = '' | |
u = c['remote.origin.url'] | |
if m = /github\.com.(.*?)\/(.*?)\.git/.match(u) | |
user = m[1] | |
proj = m[2] | |
url = "https://github.com/#{user}/#{proj}" | |
end | |
head_file = File.join(File.dirname(__FILE__), %w[.. HEAD]) | |
b = File.read(head_file) | |
branch = b.chomp.split('/').last rescue '' | |
@config = { | |
:server => c['hawk.server'], | |
:token => c['hawk.token'], | |
:agent => c['hawk.agent'], | |
:description => c['hawk.description'], | |
:branch => branch, | |
:url => url | |
} | |
end | |
def self.post_update(data) | |
config = Hawk.config | |
ws = "#{config[:server]}/update/#{config[:token]}" | |
x = Net::HTTP.post_form(URI.parse(ws), {'data' => data}) | |
puts x.body | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'rubygems' | |
require File.join(File.dirname(__FILE__), "hawk") | |
status = ARGV[0] | |
Hawk.post(status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment