Class: Engineyard::Hudson::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/engineyard-hudson/cli.rb

Instance Method Summary collapse

Instance Method Details

#install(project_path) ⇒ Object



10
11
12
13
# File 'lib/engineyard-hudson/cli.rb', line 10

def install(project_path)
  require 'engineyard-hudson/cli/install'
  Engineyard::Hudson::Install.start(project_path)
end

#install_server(project_path = nil) ⇒ Object

Generates a chef recipe cookbook, uploads it to AppCloud, and waits until Hudson CI has launched



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/engineyard-hudson/cli.rb', line 20

def install_server(project_path=nil)
  environments = Engineyard::Hudson::AppcloudEnv.new.find_environments(options)
  if environments.size == 0
    no_environments_discovered and return
  elsif environments.size > 1
    too_many_environments_discovered(environments) and return
  end
  
  env_name, , environment = environments.first
  if environment.instances.first
    public_hostname = environment.instances.first.public_hostname
    status          = environment.instances.first.status
  end
  
  temp_project_path = File.expand_path(project_path || File.join(Dir.tmpdir, "temp_hudson_server"))
  shell.say "Temp installation dir: #{temp_project_path}" if options[:verbose]
  
  FileUtils.mkdir_p(temp_project_path)
  FileUtils.chdir(FileUtils.mkdir_p(temp_project_path)) do
    # 'install_server' generator
    require 'engineyard-hudson/cli/install_server'
    Engineyard::Hudson::InstallServer.start(ARGV.unshift(temp_project_path))

    say ""
    say "Uploading to "; say "'#{env_name}' ", :yellow; say "environment on "; say "'#{}' ", :yellow; say "account..."
    require 'engineyard/cli/recipes'
    environment.upload_recipes
    
    if status == "running"
      say "Environment is rebuilding..."
      environment.run_custom_recipes
      watch_page_while public_hostname, 80, "/" do |req|
        req.body !~ /Please wait while Hudson is getting ready to work/
      end

      say ""
      say "Hudson is starting..."
      watch_page_while public_hostname, 80, "/" do |req|
        req.body =~ /Please wait while Hudson is getting ready to work/
      end
      
      require 'hudson'
      require 'hudson/config'
      ::Hudson::Config.config["base_uri"] = public_hostname
      ::Hudson::Config.store!
      
      say ""
      say "Done! Hudson CI hosted at "; say "http://#{public_hostname}", :green
    else
      say ""
      say "Almost there..."
      say "* Boot your environment via https://cloud.engineyard.com", :yellow
    end
  end
end

#versionObject



77
78
79
80
# File 'lib/engineyard-hudson/cli.rb', line 77

def version
  require 'engineyard-hudson/version'
  shell.say Engineyard::Hudson::VERSION
end