Class: BuildingController
Instance Method Summary
collapse
#active_tab
#sshkey_uploaded?
#domain_is_missing, #user_default_domain
#user_capabilities
Instance Method Details
#create ⇒ Object
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
|
# File 'app/controllers/building_controller.rb', line 21
def create
@domain = Domain.find :one, :as => current_user
@application = @domain.find_application(params[:application_id])
@jenkins_server = @domain.find_application(@application.building_app) if @application.building_app
@cartridge_type = CartridgeType.cached.all.find{ |c| c.tags.include? :ci_builder }
@cartridge = Cartridge.new :name => @cartridge_type.name
unless @jenkins_server
framework = CartridgeType.cached.all.find{ |c| c.tags.include? :ci }
@jenkins_server = Application.new(
:name => params[:application][:name],
:cartridge => framework.name,
:domain => @domain,
:as => current_user)
if @jenkins_server.save
message = @jenkins_server.remote_results
else
render :new and return
end
end
@cartridge.application = @application
success, attempts = @cartridge.save, 1
while (!success && @cartridge.has_exit_code?(157, :on => :cartridge) && attempts < 2)
logger.debug " Jenkins server could not be contacted, sleep and then retry\n #{@cartridge.errors.inspect}"
sleep(10)
success = @cartridge.save
attempts += 1
end
if success
redirect_to application_building_path(@application), :flash => {:info_pre => @cartridge.remote_results.concat(message || []).concat(['Your application is now building with Jenkins.'])}
else
if @cartridge.has_exit_code?(157, :on => :cartridge)
message = 'The Jenkins server is not yet registered with DNS. Please wait a few minutes before trying again.'
else
@cartridge.errors.full_messages.each{ |m| @jenkins_server.errors.add(:base, m) }
end
flash.now[:info_pre] = message
render :new
end
end
|
#delete ⇒ Object
66
67
68
69
70
|
# File 'app/controllers/building_controller.rb', line 66
def delete
user_default_domain
@application = @domain.find_application params[:application_id]
redirect_to new_application_building_path(@application) unless @application.builds?
end
|
#destroy ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'app/controllers/building_controller.rb', line 72
def destroy
@domain = Domain.find :one, :as => current_user
@application = @domain.find_application params[:application_id]
if @application.destroy_build_cartridge
redirect_to application_path(@application), :flash => {:success => "#{@application.name} is no longer building through Jenkins."}
else
render :delete
end
end
|
#new ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/building_controller.rb', line 9
def new
user_default_domain
@application = @domain.find_application params[:application_id]
@jenkins_server = if @application.building_app
@domain.find_application(@application.building_app) if @application.building_app
else
Application.new({:name => 'jenkins'}, false)
end
@cartridge_type = CartridgeType.cached.all.find{ |c| c.tags.include? :ci_builder }
@cartridge = Cartridge.new :name => @cartridge_type.name
end
|
#show ⇒ Object
3
4
5
6
7
|
# File 'app/controllers/building_controller.rb', line 3
def show
user_default_domain
@application = @domain.find_application params[:application_id]
redirect_to new_application_building_path(@application) unless @application.builds?
end
|