Created
October 27, 2010 21:07
-
-
Save techpeace/649998 to your computer and use it in GitHub Desktop.
Polls your git repo and kicks off CI Joe builds upon new commits. Useful for CI Joe servers running behind a firewall.
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 'yaml' | |
require 'net/http' | |
PROJECT_PATH = '/Users/mbuck/src/applicant_portal/hr_suite' | |
PORT = 3000 | |
def current_sha | |
`cd #{PROJECT_PATH} && git rev-parse origin/master`.chomp | |
end | |
def last_built_sha | |
last_build_file = File.join(PROJECT_PATH, '.git', 'builds', 'last') | |
current_build_file = File.join(PROJECT_PATH, '.git', 'builds', 'current') | |
if File.exist?(last_build_file) && !File.exist?(current_build_file) | |
config = YAML.load(File.read(last_build_file)) | |
return config[4] | |
end | |
return false | |
end | |
def git_update | |
`cd #{PROJECT_PATH} && git fetch origin && git reset --hard origin/master` | |
end | |
while true | |
git_update | |
last = last_built_sha | |
current = current_sha | |
if last && (last != current) | |
Net::HTTP.post_form(URI.parse("http://0.0.0.0:#{PORT.to_s}/"), {'build' => 'now'}) | |
end | |
sleep 60 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this with nohup, a là
nohup cijoe_github_poller.rb &