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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/engineyard-jenkins/cli.rb', line 34
def install_server(project_path=nil)
environments = Engineyard::Jenkins::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_jenkins_server"))
shell.say "Temp installation dir: #{temp_project_path}" if options[:verbose]
FileUtils.mkdir_p(temp_project_path)
FileUtils.chdir(temp_project_path) do
require 'engineyard-jenkins/cli/install_server_generator'
Engineyard::Jenkins::InstallServerGenerator.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.tar_and_upload_recipes_in_cookbooks_dir
if status == "running" || status == "error"
say "Environment is rebuilding..."
environment.run_custom_recipes
watch_page_while public_hostname, 80, "/" do |req|
req.body !~ /Please wait while Jenkins is getting ready to work/
end
say ""
say "Jenkins is starting..."
watch_page_while public_hostname, 80, "/" do |req|
req.body =~ /Please wait while Jenkins is getting ready to work/
end
require 'jenkins'
require 'jenkins/config'
::Jenkins::Config.config["base_uri"] = public_hostname
::Jenkins::Config.store!
say ""
say "Done! Jenkins 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
|