From e06fa58e7f2c22c0fe62ee330c2f496025cff231 Mon Sep 17 00:00:00 2001 From: stellsmi Date: Mon, 22 Jan 2007 17:50:46 +0000 Subject: [PATCH] getting executables a bit slicker and dropping the gem idea git-svn-id: http://cruisecontrolrb.rubyforge.org/svn/trunk@13 c04ce798-636b-4ca8-9149-0f9336831111 --- bin/builder | 81 ------------------------------------ bin/cruise => cruise | 31 ++------------ cruise.cmd | 1 + lib/cruisecontrol/version.rb | 2 +- {bin => script}/add_project | 0 script/builder | 33 +++++++-------- 6 files changed, 21 insertions(+), 127 deletions(-) delete mode 100644 bin/builder rename bin/cruise => cruise (58%) create mode 100644 cruise.cmd rename {bin => script}/add_project (100%) diff --git a/bin/builder b/bin/builder deleted file mode 100644 index 21480f6..0000000 --- a/bin/builder +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env ruby -ENV["RAILS_ENV"] = 'production' -require File.dirname(__FILE__) + '/../config/boot' -require 'optparse' - -OPTIONS = { :verbose => false } - -project_name = nil - -ARGV.options do |opts| - script_name = File.basename($0) - opts.banner = "Usage: cruise builder []options]" - - opts.separator "" - - opts.on("-v", "--verbose", "Verbose logging") { OPTIONS[:verbose] = true } - opts.on("-h", "--help", - "Show this help message.") { puts opts; exit } - - args = opts.parse! - - unless args.length == 1 - STDERR.puts "Project name not specified" - STDERR.puts - puts opts - exit(-1) - end - - project_name = args[0] -end - -require RAILS_ROOT + "/config/environment" - -project_path = File.expand_path(File.join(Configuration.builds_directory, project_name)) - -unless File.exist? project_path - STDERR.puts "Project '#{project_name}' not found in '#{project_path}'" - exit(-1) -end - -begin - Log.verbose = OPTIONS[:verbose] - project = Project.load_or_create(project_path) - - # this will create builder.pid file in project's CC directory and grab an exclusive lock on it, or else blow up saying - # that something else is already locking it - ProjectBlocker.block(project) - - STDOUT.puts "Builder for project '#{project.name}' started" - Log.event "Builder for project '#{project.name}' started" - - Schedule.new(project, :poll_interval_sec => 10).run -rescue => e - begin - Log.error(e.message) - Log.error(e.backtrace) - rescue => logging_error - STDERR.puts e.message - STDERR.puts e.backtrace - STDERR.puts "Attempt to log the above error failed with this:" - STDERR.puts logging_error.message - STDERR.puts logging_error.backtrace - end - if (OPTIONS[:verbose]) - raise - else - STDERR.puts e.message - exit(1) - end -end - - -at_exit do - begin - Log.event "Builder for project '#{project.name}' stopped" - STDOUT.puts "Builder for project '#{project.name}' stopped" - ProjectBlocker.release(project) - rescue - # ignore logging errors - end -end \ No newline at end of file diff --git a/bin/cruise b/cruise similarity index 58% rename from bin/cruise rename to cruise index f4ff266..001c502 100644 --- a/bin/cruise +++ b/cruise @@ -1,43 +1,21 @@ #!/usr/bin/env ruby ENV["RAILS_ENV"] = 'production' -require File.dirname(__FILE__) + '/../config/boot' +require File.dirname(__FILE__) + '/config/boot' require 'optparse' require 'cruisecontrol/version' -def find_builds - site_config = File.dirname(__FILE__) + "/../config/site_config.rb" - return if File.exist?(site_config) - - print %{It looks like this is the first time you've run CruiseControl.rb. Where would you like your us to -build your projects? eg. c:\\cruisecontrol or ~/builds - - > } - - builds_dir = $stdin.gets.strip - unless File.directory? builds_dir - require 'fileutils' - FileUtils.makedirs builds_dir - unless File.directory? builds_dir - STDERR.puts "couldn't create #{builds_dir}" - exit -1 - end - end - - File.open(site_config, 'w') {|f| f << "Configuration.builds_directory = '#{builds_dir}'" } -end - def start ARGV.unshift "99" ARGV.unshift "-p" - load File.dirname(__FILE__) + "/../script/server" + load File.dirname(__FILE__) + "/script/server" end def add - load File.dirname(__FILE__) + "/add_project" + load File.dirname(__FILE__) + "/script/add_project" end def builder - load File.dirname(__FILE__) + "/builder" + load File.dirname(__FILE__) + "/script/builder" end def version @@ -65,7 +43,6 @@ For additional information, see http://cruisecontrolrb.rubyforge.org/ EOL end -find_builds action = ARGV.shift case action diff --git a/cruise.cmd b/cruise.cmd new file mode 100644 index 0000000..31e0fb5 --- /dev/null +++ b/cruise.cmd @@ -0,0 +1 @@ +@ruby cruise %* \ No newline at end of file diff --git a/lib/cruisecontrol/version.rb b/lib/cruisecontrol/version.rb index 1762b47..d7e7ed5 100644 --- a/lib/cruisecontrol/version.rb +++ b/lib/cruisecontrol/version.rb @@ -1,7 +1,7 @@ module CruiseControl module VERSION #:nodoc: MAJOR = 0 - MINOR = 1 + MINOR = 2 STRING = [MAJOR, MINOR].join('.') end diff --git a/bin/add_project b/script/add_project similarity index 100% rename from bin/add_project rename to script/add_project diff --git a/script/builder b/script/builder index cb25143..21480f6 100644 --- a/script/builder +++ b/script/builder @@ -1,49 +1,46 @@ #!/usr/bin/env ruby - -ENV["RAILS_ENV"] = 'builder' - +ENV["RAILS_ENV"] = 'production' require File.dirname(__FILE__) + '/../config/boot' - require 'optparse' OPTIONS = { :verbose => false } +project_name = nil + ARGV.options do |opts| script_name = File.basename($0) - opts.banner = "Usage: ruby #{script_name} [options]" + opts.banner = "Usage: cruise builder []options]" opts.separator "" - opts.on("-p", "--project=name", String, - "Project name to build. This option must be specified.") { |v| OPTIONS[:project_name] = v } - opts.on("-c", "--checkout=directory", String, - "Where the project's local copy checked out from source control is", - "Default: ccrb/builds//work") { |v| OPTIONS[:checkout_directory] = v } opts.on("-v", "--verbose", "Verbose logging") { OPTIONS[:verbose] = true } - - opts.separator "" - opts.on("-h", "--help", "Show this help message.") { puts opts; exit } - opts.parse! + args = opts.parse! - unless OPTIONS[:project_name] + unless args.length == 1 STDERR.puts "Project name not specified" STDERR.puts puts opts exit(-1) end - OPTIONS[:checkout_directory] ||= File.join(RAILS_ROOT, 'builds', OPTIONS[:project_name]) - OPTIONS[:checkout_directory] = File.expand_path(OPTIONS[:checkout_directory]) + project_name = args[0] end require RAILS_ROOT + "/config/environment" +project_path = File.expand_path(File.join(Configuration.builds_directory, project_name)) + +unless File.exist? project_path + STDERR.puts "Project '#{project_name}' not found in '#{project_path}'" + exit(-1) +end + begin Log.verbose = OPTIONS[:verbose] - project = Project.load_or_create(OPTIONS[:checkout_directory]) + project = Project.load_or_create(project_path) # this will create builder.pid file in project's CC directory and grab an exclusive lock on it, or else blow up saying # that something else is already locking it