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, account_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
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 "'#{account_name}' ", :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
|