#!/usr/bin/env ruby ENV["RAILS_ENV"] = 'production' require File.dirname(__FILE__) + '/../config/boot' require 'optparse' project_name = ARGV.shift trace = false scm_options = {:interactive => true} ARGV.options do |opts| opts.banner = "usage: cruise add --url [subversion options]" opts.separator "" opts.on("-u", "--url url", String, "The subversion url for the project (eg. svn://rubyforge.org/var/svn/cruisecontrolrb)") do |v| scm_options[:url] = v end opts.on("--username username", String, "Specify a username for source control") { |v| scm_options[:username] = v } opts.on("--password password", String, "Specify a password for source control") { |v| scm_options[:password] = v } opts.on('-t', '--trace', 'Print out exception stack traces') { trace = true } opts.separator "" opts.on("-h", "--help", "Show this help message.") { puts opts; exit 1 } args = opts.parse! unless project_name and scm_options[:url] STDERR.puts "Project name and url are mandatory" STDERR.puts puts opts exit(-1) end # Project Name can only contain alphanumeric characters if project_name.match /[^-_a-zA-Z0-9]/ STDERR.puts "'#{project_name}' is not a valid project name. Project name should only contain alphanumeric " + 'characters, dashes and underscores, and no whitespace.' exit(-1) end end puts "Adding project '#{project_name}' (this may take a while)..." begin require RAILS_ROOT + "/config/environment" source_control = Subversion.new(scm_options) project = Project.new(project_name, source_control) projects = Projects.load_all projects << project if source_control.url =~ /^svn\+ssh\:\/\// puts "IMPORTANT!!! - It looks like you are connecting to your repository with an svn+ssh connection. " + "For cruise to build this project, you need to have set up authentication caching for ssh, see this article" puts " http://subversion.tigris.org/faq.html#ssh-auth-cache" puts end rescue => e if trace raise else STDERR.puts "FAILED: #{e.message}" exit -1 end end puts "Project '#{project_name}' added."