Sha256: ec3784520cfde5afb13d6971467929ddaf9509ee2ac7cf8b1ce3764f8318ee3a

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'uri'
require 'fileutils'
require 'net/http'
require 'cijoe/build'
require 'choice'

Choice.options do
  header ''
  header 'Specific options:'

  option :host do
    short '-h'
    long '--host=HOST'
    desc 'The hostname or ip of the host running buildboard (default 127.0.0.1)'
    default '127.0.0.1'
  end

  option :port do
    short '-p'
    long '--port=PORT'
    desc 'The port buildboard is running on (default 5678)'
    cast Integer
    default 5678
  end

  option :directory do
    short '-d'
    long '--directory=DIRECTORY'
    desc 'The directory containing the CI Joe repository'
  end

  separator ''
  separator 'Common options: '

  option :help do
    long '--help'
    desc 'Show this message'
  end
end

puts "You must supply a directory" and exit 1 unless Choice.choices[:directory]

build_file = File.join(Choice.choices[:directory], '.git', 'builds', 'last')
raise("Couldn't find file #{build_file}") unless File.exists?(build_file)
build = CIJoe::Build.load(build_file)
Net::HTTP.post_form(URI.parse("http://#{Choice.choices[:host]}:#{Choice.choices[:port]}/"),
                    {
                      :output => build.output,
                      :status => build.status == :failed ? 'failed' : 'success',
                      :sha => build.sha,
                      :started_at => build.started_at,
                      :finished_at => build.finished_at,
                      :project => build.project,
                      :git => `git log -1 #{build.sha}`
                    })

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
buildboard-0.1.2 bin/update-buildboard
buildboard-0.1.1 bin/update-buildboard
buildboard-0.1.0 bin/update-buildboard