Merge pull request #81 from warpc/80-bl_publish
Support build list publication as delayed task
This commit is contained in:
commit
687fa3e000
|
@ -1,12 +1,12 @@
|
|||
class BuildListsController < ApplicationController
|
||||
CALLBACK_ACTIONS = [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
|
||||
CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
|
||||
NESTED_ACTIONS = [:index, :new, :create]
|
||||
|
||||
before_filter :authenticate_user!, :except => CALLBACK_ACTIONS
|
||||
before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS
|
||||
before_filter :find_project, :only => NESTED_ACTIONS
|
||||
before_filter :find_build_list, :only => [:show, :publish, :cancel]
|
||||
before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build, :post_build]
|
||||
before_filter :find_build_list_by_bs, :only => [:publish_build, :status_build, :pre_build, :post_build]
|
||||
|
||||
load_and_authorize_resource :project, :only => NESTED_ACTIONS
|
||||
load_and_authorize_resource :through => :project, :only => NESTED_ACTIONS, :shallow => true
|
||||
|
@ -79,6 +79,14 @@ class BuildListsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def publish_build
|
||||
@build_list.status = (params[:status].to_i == 0 ? BuildList::BUILD_PUBLISHED : BuildList::FAILED_PUBLISH)
|
||||
@build_list.notified_at = Time.current
|
||||
@build_list.save
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
||||
def status_build
|
||||
@item = @build_list.items.find_by_name!(params[:package_name])
|
||||
@item.status = params[:status]
|
||||
|
|
|
@ -21,11 +21,15 @@ class BuildList < ActiveRecord::Base
|
|||
WAITING_FOR_RESPONSE = 4000
|
||||
BUILD_PENDING = 2000
|
||||
BUILD_PUBLISHED = 6000
|
||||
BUILD_PUBLISH = 7000
|
||||
FAILED_PUBLISH = 8000
|
||||
|
||||
STATUSES = [ WAITING_FOR_RESPONSE,
|
||||
BUILD_CANCELED,
|
||||
BUILD_PENDING,
|
||||
BUILD_PUBLISHED,
|
||||
BUILD_PUBLISH,
|
||||
FAILED_PUBLISH,
|
||||
BuildServer::SUCCESS,
|
||||
BuildServer::BUILD_STARTED,
|
||||
BuildServer::BUILD_ERROR,
|
||||
|
@ -40,6 +44,8 @@ class BuildList < ActiveRecord::Base
|
|||
BUILD_CANCELED => :build_canceled,
|
||||
BUILD_PENDING => :build_pending,
|
||||
BUILD_PUBLISHED => :build_published,
|
||||
BUILD_PUBLISH => :build_publish,
|
||||
FAILED_PUBLISH => :failed_publish,
|
||||
BuildServer::BUILD_ERROR => :build_error,
|
||||
BuildServer::BUILD_STARTED => :build_started,
|
||||
BuildServer::SUCCESS => :success,
|
||||
|
@ -106,13 +112,13 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
def publish
|
||||
has_published = BuildServer.publish_container bs_id
|
||||
update_attribute(:status, BUILD_PUBLISHED) if has_published == 0
|
||||
update_attribute(:status, BUILD_PUBLISH) if has_published == 0
|
||||
|
||||
return has_published == 0
|
||||
end
|
||||
|
||||
def can_publish?
|
||||
self.status == BuildServer::SUCCESS
|
||||
status == BuildServer::SUCCESS or status == FAILED_PUBLISH
|
||||
end
|
||||
|
||||
def cancel
|
||||
|
@ -124,7 +130,7 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
#TODO: Share this checking on product owner.
|
||||
def can_cancel?
|
||||
self.status == BUILD_PENDING && bs_id
|
||||
status == BUILD_PENDING && bs_id
|
||||
end
|
||||
|
||||
def event_log_message
|
||||
|
|
|
@ -294,7 +294,7 @@ ru:
|
|||
cancel_button: Отмена
|
||||
cancel_success: 'Сборка отменена.'
|
||||
cancel_fail: 'При отмене сборки произошла ошибка!'
|
||||
publish_success: 'Сборка опубликована.'
|
||||
publish_success: 'Сборка поставлена в очередь на публикацию.'
|
||||
publish_fail: 'При публикации сборки произошла ошибка!'
|
||||
|
||||
build_server_status:
|
||||
|
@ -314,6 +314,8 @@ ru:
|
|||
statuses:
|
||||
build_error: ошибка сборки
|
||||
build_published: опубликован
|
||||
build_publish: публикуется
|
||||
failed_publish: ошибка публикации
|
||||
dependencies_fail: зависимости не найдены
|
||||
waiting_for_response: ожидает ответа
|
||||
build_pending: ожидает сборку
|
||||
|
|
|
@ -24,6 +24,7 @@ Rosa::Application.routes.draw do
|
|||
|
||||
match '/private/:platform_name/*file_path' => 'privates#show'
|
||||
|
||||
match 'build_lists/publish_build', :to => "build_lists#publish_build"
|
||||
match 'build_lists/status_build', :to => "build_lists#status_build"
|
||||
match 'build_lists/post_build', :to => "build_lists#post_build"
|
||||
match 'build_lists/pre_build', :to => "build_lists#pre_build"
|
||||
|
|
Loading…
Reference in New Issue