[refs #762] add mass build from list
This commit is contained in:
parent
195fd16e21
commit
dc1525b85e
|
@ -12,7 +12,8 @@ class Platforms::MassBuildsController < Platforms::BaseController
|
|||
def create
|
||||
mass_build = @platform.mass_builds.new(:repositories => params[:repositories],
|
||||
:arches => params[:arches],
|
||||
:auto_publish => params[:auto_publish] || false)
|
||||
:auto_publish => params[:auto_publish] || false,
|
||||
:projects_list => params[:projects_list])
|
||||
mass_build.user = current_user
|
||||
authorize! :create, mass_build
|
||||
|
||||
|
@ -40,7 +41,12 @@ class Platforms::MassBuildsController < Platforms::BaseController
|
|||
redirect_to platform_mass_builds_path(@mass_build.platform)
|
||||
end
|
||||
|
||||
def failed_builds_list
|
||||
render :text => @mass_build.generate_failed_builds_list
|
||||
def get_list
|
||||
text = if params[:kind] == 'failed_builds_list'
|
||||
@mass_build.generate_failed_builds_list
|
||||
elsif ['projects_list', 'missed_projects_list'].include? params[:kind]
|
||||
@mass_build.send params[:kind]
|
||||
end
|
||||
render :text => text
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module MassBuildHelper
|
||||
def link_to_list platform, mass_build, which
|
||||
link_to t("layout.mass_builds.#{which}"),
|
||||
get_list_platform_mass_build_path(@platform, mass_build, :kind => which, :format => :txt),
|
||||
:target => "_blank" if can?(:get_list, mass_build)
|
||||
end
|
||||
end
|
|
@ -95,7 +95,7 @@ class Ability
|
|||
can([:update, :members], Platform) {|platform| local_admin? platform}
|
||||
can([:destroy, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
|
||||
|
||||
can([:failed_builds_list, :create], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main? }
|
||||
can([:get_list, :create], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main?}
|
||||
can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && mass_build.platform.main?}
|
||||
|
||||
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
|
||||
|
@ -151,7 +151,7 @@ class Ability
|
|||
cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'}
|
||||
cannot [:clone], Platform, :platform_type => 'personal'
|
||||
|
||||
cannot([:failed_builds_list, :create], MassBuild) {|mass_build| mass_build.platform.personal?}
|
||||
cannot([:get_list, :create], MassBuild) {|mass_build| mass_build.platform.personal?}
|
||||
cannot(:cancel, MassBuild) {|mass_build| mass_build.platform.personal? || mass_build.stop_build}
|
||||
|
||||
can :create, Subscribe do |subscribe|
|
||||
|
|
|
@ -7,9 +7,10 @@ class MassBuild < ActiveRecord::Base
|
|||
scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME)
|
||||
|
||||
attr_accessor :repositories, :arches
|
||||
attr_accessible :repositories, :arches, :auto_publish
|
||||
attr_accessible :repositories, :arches, :auto_publish, :projects_list
|
||||
|
||||
validates :platform_id, :arch_names, :name, :user_id, :repositories, :rep_names, :presence => true
|
||||
validates :platform_id, :arch_names, :name, :user_id, :presence => true
|
||||
validate :rep_names, :repositories, :presence => true, :if => Proc.new {|mb| mb.projects_list.blank?}
|
||||
validates_inclusion_of :auto_publish, :in => [true, false]
|
||||
|
||||
after_create :build_all
|
||||
|
@ -26,13 +27,18 @@ class MassBuild < ActiveRecord::Base
|
|||
|
||||
# ATTENTION: repositories and arches must be set before calling this method!
|
||||
def build_all
|
||||
platform.build_all(
|
||||
:mass_build_id => self.id,
|
||||
:user => self.user,
|
||||
:repositories => self.repositories,
|
||||
:arches => self.arches,
|
||||
:auto_publish => self.auto_publish
|
||||
) # later with resque
|
||||
# later with resque
|
||||
if projects_list.present?
|
||||
platform.build_from_list :mass_build_id => self.id
|
||||
else
|
||||
platform.build_all(
|
||||
:mass_build_id => self.id,
|
||||
:user => self.user,
|
||||
:repositories => self.repositories,
|
||||
:arches => self.arches,
|
||||
:auto_publish => self.auto_publish
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def generate_failed_builds_list
|
||||
|
|
|
@ -205,6 +205,32 @@ class Platform < ActiveRecord::Base
|
|||
end
|
||||
later :build_all, :loner => true, :queue => :clone_build
|
||||
|
||||
def build_from_list(opts={})
|
||||
mass_build = MassBuild.find opts[:mass_build_id]
|
||||
arches = mass_build.arches ? Arch.where(:id => mass_build.arches) : Arch.all
|
||||
auto_publish = opts[:auto_publish] || false
|
||||
user = opts[:user]
|
||||
|
||||
mass_build.projects_list.lines.each do |name|
|
||||
name.chomp!; name.strip!
|
||||
if p = Project.joins(:repositories).where('repositories.id IN (?)', repositories).find_by_name(name)
|
||||
begin
|
||||
return if mass_build.reload.stop_build
|
||||
p.build_for(self, rep.id, user, arch, auto_publish, mass_build_id)
|
||||
rescue RuntimeError, Exception
|
||||
end
|
||||
else
|
||||
MassBuild.increment_counter :missed_projects_count, mass_build.id
|
||||
#mass_build.missed_projects_list = '' if mass_build.missed_projects_list.nil?
|
||||
#mass_build.missed_projects_list << "#{name}\n"
|
||||
list = (mass_build.missed_projects_list || '') << "#{name}\n"
|
||||
mass_build.update_column :missed_projects_list, list
|
||||
end
|
||||
sleep 0.2
|
||||
end
|
||||
end
|
||||
later :build_from_list, :loner => true, :queue => :clone_build
|
||||
|
||||
def destroy
|
||||
with_skip {super} # avoid cascade XML RPC requests
|
||||
end
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
.both
|
||||
= check_box_tag "repositories[]", rep.id, (params[:repositories]||[]).include?(rep.id.to_s), :id => "repositories_#{rep.id}"
|
||||
= label_tag "repositories_#{rep.id}", rep.name
|
||||
%h3= t("layout.mass_builds.projects_list")
|
||||
= text_area_tag :projects_list, nil
|
||||
%br
|
||||
= f.submit t("layout.projects.build_button")
|
||||
%section.right
|
||||
|
@ -43,11 +45,19 @@
|
|||
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
|
||||
= mass_build.read_attribute "#{status}_count"
|
||||
.both
|
||||
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build)
|
||||
%td
|
||||
=link_to_list @platform, mass_build, 'failed_builds_list'
|
||||
-if mass_build.projects_list.present?
|
||||
%br
|
||||
=link_to_list @platform, mass_build, 'missed_projects_list'
|
||||
%td= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel, mass_build)
|
||||
%td
|
||||
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
|
||||
.toggle{:id => "toggle_#{ mass_build.id }"}
|
||||
-if mass_build.projects_list.present?
|
||||
= t('activerecord.attributes.mass_build.projects_list') + ": "
|
||||
= link_to_list @platform, mass_build, 'projects_list'
|
||||
.both
|
||||
= t('activerecord.attributes.mass_build.arch_names') + ": "
|
||||
= mass_build.arch_names
|
||||
.both
|
||||
|
|
|
@ -7,6 +7,8 @@ en:
|
|||
statuses: Statuses
|
||||
cancel_mass_build: Cancel
|
||||
cancel_confirm: Are you sure you want to cancel mass build?
|
||||
projects_list: Projects list
|
||||
missed_projects_list: Missed projects list
|
||||
activerecord:
|
||||
models:
|
||||
mass_build: Mass Build
|
||||
|
|
|
@ -7,6 +7,8 @@ ru:
|
|||
statuses: Статусы
|
||||
cancel_mass_build: Отмена
|
||||
cancel_confirm: Вы уверены, что хотите отменить массовую сборку?
|
||||
projects_list: Список проектов
|
||||
missed_projects_list: Список несуществующих проектов
|
||||
activerecord:
|
||||
models:
|
||||
mass_build: Массовая Сборка
|
||||
|
|
|
@ -131,8 +131,8 @@ Rosa::Application.routes.draw do
|
|||
|
||||
resources :mass_builds, :only => [:create, :index] do
|
||||
member do
|
||||
get :failed_builds_list
|
||||
post :cancel
|
||||
get '/:kind.:format' => "mass_builds#get_list", :as => :get_list, :kind => /failed_builds_list|missed_projects_list|projects_list/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class AddListToMassBuild < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :mass_builds, :projects_list, :text
|
||||
add_column :mass_builds, :missed_projects_count, :integer, :default => 0, :null => false
|
||||
add_column :mass_builds, :missed_projects_list, :text
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20121203142727) do
|
||||
ActiveRecord::Schema.define(:version => 20121206143724) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -252,6 +252,9 @@ ActiveRecord::Schema.define(:version => 20121203142727) do
|
|||
t.integer "build_error_count", :default => 0, :null => false
|
||||
t.string "rep_names"
|
||||
t.boolean "stop_build", :default => false, :null => false
|
||||
t.text "projects_list"
|
||||
t.integer "missed_projects_count", :default => 0, :null => false
|
||||
t.text "missed_projects_list"
|
||||
end
|
||||
|
||||
create_table "platforms", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue