2011-04-07 14:20:21 +01:00
|
|
|
class BuildListsController < ApplicationController
|
2011-11-30 00:56:57 +00:00
|
|
|
CALLBACK_ACTIONS = [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
|
2011-11-19 11:41:11 +00:00
|
|
|
|
2011-11-30 00:56:57 +00:00
|
|
|
before_filter :authenticate_user!, :except => CALLBACK_ACTIONS
|
|
|
|
before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS
|
|
|
|
before_filter :find_project, :only => [:index, :filter, :show, :publish]
|
|
|
|
before_filter :find_arches, :only => [:index, :filter, :all]
|
|
|
|
before_filter :find_project_versions, :only => [:index, :filter]
|
|
|
|
before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build, :post_build]
|
|
|
|
|
|
|
|
load_and_authorize_resource :except => CALLBACK_ACTIONS
|
2011-10-28 18:55:40 +01:00
|
|
|
|
2011-10-22 16:28:41 +01:00
|
|
|
def all
|
|
|
|
if params[:filter]
|
|
|
|
@filter = BuildList::Filter.new(nil, params[:filter])
|
|
|
|
@build_lists = @filter.find.paginate :page => params[:page]
|
|
|
|
else
|
|
|
|
@filter = BuildList::Filter.new(nil)
|
2011-11-02 08:27:14 +00:00
|
|
|
@build_lists = BuildList.recent.paginate :page => params[:page]
|
2011-04-07 15:56:28 +01:00
|
|
|
end
|
2011-10-22 16:28:41 +01:00
|
|
|
@action_url = all_build_lists_path
|
2011-10-29 14:38:01 +01:00
|
|
|
|
|
|
|
@build_server_status = BuildServer.get_status
|
|
|
|
|
2011-10-22 16:28:41 +01:00
|
|
|
render :action => 'index'
|
|
|
|
end
|
|
|
|
|
|
|
|
def cancel
|
2011-11-19 11:41:11 +00:00
|
|
|
build_list = BuildList.find(params[:id])
|
|
|
|
if build_list.delete_build_list
|
|
|
|
redirect_to :back, :notice => t('layout.build_lists.cancel_successed')
|
|
|
|
else
|
|
|
|
redirect_to :back, :notice => t('layout.build_lists.cancel_failed')
|
|
|
|
end
|
2011-10-22 16:28:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
@build_lists = @project.build_lists.recent.paginate :page => params[:page]
|
|
|
|
@filter = BuildList::Filter.new(@project)
|
2011-10-23 07:49:56 +01:00
|
|
|
@action_url = project_build_lists_path(@project)
|
2011-10-22 16:28:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def filter
|
|
|
|
@filter = BuildList::Filter.new(@project, params[:filter])
|
|
|
|
@build_lists = @filter.find.paginate :page => params[:page]
|
2011-10-23 07:49:56 +01:00
|
|
|
@action_url = project_build_lists_path(@project)
|
2011-10-22 16:28:41 +01:00
|
|
|
|
|
|
|
render :action => "index"
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@build_list = @project.build_lists.find(params[:id])
|
|
|
|
@item_groups = @build_list.items.group_by_level
|
|
|
|
end
|
|
|
|
|
|
|
|
def publish
|
|
|
|
@build_list = @project.build_lists.find(params[:id])
|
|
|
|
@build_list.publish
|
|
|
|
|
2011-10-23 07:49:56 +01:00
|
|
|
redirect_to project_build_lists_path(@project)
|
2011-10-22 16:28:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def status_build
|
|
|
|
@item = @build_list.items.find_by_name!(params[:package_name])
|
|
|
|
@item.status = params[:status]
|
|
|
|
@item.save
|
|
|
|
|
|
|
|
@build_list.container_path = params[:container_path]
|
2011-11-11 17:13:09 +00:00
|
|
|
@build_list.notified_at = Time.current
|
2011-10-22 16:28:41 +01:00
|
|
|
|
|
|
|
@build_list.save
|
|
|
|
|
|
|
|
render :nothing => true, :status => 200
|
|
|
|
end
|
|
|
|
|
|
|
|
def pre_build
|
|
|
|
@build_list.status = BuildList::BUILD_STARTED
|
2011-11-11 17:13:09 +00:00
|
|
|
@build_list.notified_at = Time.current
|
2011-10-22 16:28:41 +01:00
|
|
|
|
|
|
|
@build_list.save
|
|
|
|
|
|
|
|
render :nothing => true, :status => 200
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_build
|
|
|
|
@build_list.status = params[:status]
|
|
|
|
@build_list.container_path = params[:container_path]
|
2011-11-11 17:13:09 +00:00
|
|
|
@build_list.notified_at = Time.current
|
2011-10-22 16:28:41 +01:00
|
|
|
|
|
|
|
@build_list.save
|
|
|
|
|
|
|
|
render :nothing => true, :status => 200
|
|
|
|
end
|
|
|
|
|
|
|
|
def circle_build
|
|
|
|
@build_list.is_circle = true
|
|
|
|
@build_list.container_path = params[:container_path]
|
2011-11-11 17:13:09 +00:00
|
|
|
@build_list.notified_at = Time.current
|
2011-10-22 16:28:41 +01:00
|
|
|
|
|
|
|
@build_list.save
|
|
|
|
|
|
|
|
render :nothing => true, :status => 200
|
|
|
|
end
|
|
|
|
|
|
|
|
def new_bbdt
|
|
|
|
@build_list = BuildList.find_by_id!(params[:web_id])
|
|
|
|
@build_list.name = params[:name]
|
|
|
|
@build_list.additional_repos = ActiveSupport::JSON.decode(params[:additional_repos])
|
|
|
|
@build_list.set_items(ActiveSupport::JSON.decode(params[:items]))
|
2011-11-07 22:54:25 +00:00
|
|
|
@build_list.notified_at = Time.current
|
2011-10-22 16:28:41 +01:00
|
|
|
@build_list.is_circle = (params[:is_circular] != "0")
|
|
|
|
@build_list.bs_id = params[:id]
|
|
|
|
params[:arch]
|
|
|
|
@build_list.save
|
|
|
|
|
|
|
|
render :nothing => true, :status => 200
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
2011-10-23 08:37:54 +01:00
|
|
|
|
2011-10-22 16:28:41 +01:00
|
|
|
def find_project
|
2011-10-23 07:49:56 +01:00
|
|
|
@project = Project.find params[:project_id]
|
2011-10-22 16:28:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def find_arches
|
|
|
|
@arches = Arch.recent
|
|
|
|
end
|
|
|
|
|
2011-10-23 11:34:42 +01:00
|
|
|
def find_project_versions
|
2011-10-22 16:28:41 +01:00
|
|
|
@git_repository = @project.git_repository
|
2011-11-30 00:22:26 +00:00
|
|
|
@project_versions = @project.versions
|
2011-10-22 16:28:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def find_build_list_by_bs
|
|
|
|
@build_list = BuildList.find_by_bs_id!(params[:id])
|
|
|
|
end
|
2011-04-07 15:56:28 +01:00
|
|
|
|
2011-11-26 00:54:40 +00:00
|
|
|
def authenticate_build_service!
|
|
|
|
if request.remote_ip != APP_CONFIG['build_server_ip']
|
|
|
|
render :nothing => true, :status => 403
|
|
|
|
end
|
|
|
|
end
|
2011-04-22 13:08:58 +01:00
|
|
|
end
|