fill packages of BuildList when use new_core

This commit is contained in:
Vokhmin Alexey V 2012-12-03 21:17:20 +04:00
parent 2fcc5ac6d7
commit 3ef841184c
3 changed files with 77 additions and 39 deletions

View File

@ -45,7 +45,11 @@ module BuildListsHelper
end
def container_url
"http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe
if @build_list.new_core?
@build_list.container_path
else
"http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe
end
end
def build_list_log_url(log_type)

View File

@ -138,46 +138,47 @@
= submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish'
.hr
- if @build_list.new_core?
= render 'platforms/product_build_lists/results', :pbl => @build_list
- else
%h3= t("layout.build_lists.items_header")
- if @item_groups.blank?
%h4.nomargin= t("layout.build_lists.no_items_data")
- @item_groups.each_with_index do |group, level|
- group.each do |item|
%h4.nomargin= "#{item.name} ##{level}"
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.build_list/item.name")
%th= t("activerecord.attributes.build_list/item.version")
%th= t("activerecord.attributes.build_list/item.status")
%tbody
%tr{:class => build_list_item_status_color(item.status)}
%td= item.name
%td= item.version
%td= item.human_status
.both
- if @build_list.packages.present?
.hr
%h3= t("layout.build_lists.packages_header")
%h3= t("layout.build_lists.items_header")
- if @item_groups.blank?
%h4.nomargin= t("layout.build_lists.no_items_data")
- @item_groups.each_with_index do |group, level|
- group.each do |item|
%h4.nomargin= "#{item.name} ##{level}"
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.build_list/package.fullname")
%th= t("activerecord.attributes.build_list/package.name")
%th= t("activerecord.attributes.build_list/package.version")
%th= t("activerecord.attributes.build_list/package.release")
%th= t("activerecord.attributes.build_list/item.name")
%th= t("activerecord.attributes.build_list/item.version")
%th= t("activerecord.attributes.build_list/item.status")
%tbody
- @build_list.packages.each do |package|
%tr
%td= package.fullname
%td= package.name
%td= package.version
%td= package.release
.both
%tr{:class => build_list_item_status_color(item.status)}
%td= item.name
%td= item.version
%td= item.human_status
.both
- if @build_list.packages.present?
.hr
%h3= t("layout.build_lists.packages_header")
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.build_list/package.fullname")
%th= t("activerecord.attributes.build_list/package.name")
%th= t("activerecord.attributes.build_list/package.version")
%th= t("activerecord.attributes.build_list/package.release")
%tbody
- @build_list.packages.each do |package|
%tr
%td= package.fullname
%td= package.name
%td= package.version
%td= package.release
.both
- if @build_list.new_core?
.hr
= render 'platforms/product_build_lists/results', :pbl => @build_list
:javascript
$('article .all').addClass('bigpadding');

View File

@ -5,19 +5,52 @@ module AbfWorker
def self.perform(options)
bl = BuildList.find options['id']
status = options['status'].to_i
item = find_or_create_item(bl)
case status
when 0
bl.build_success
item.update_attributes({:status => BuildServer::SUCCESS})
when 1
bl.build_error
item.update_attributes({:status => BuildServer::BUILD_ERROR})
when 3
bl.bs_id = bl.id
bl.save
bl.save!
bl.start_build
end
if status != 3
fill_container_data bl, options
end
end
class << self
protected
def find_or_create_item(bl)
bl.items.first || bl.items.create({
:version => bl.project_version,
:name => bl.project.name,
:status => BuildServer::BUILD_STARTED,
:level => 0
})
end
def fill_container_data(bl, options)
packages = options['packages'] || []
packages.each do |package|
package = bl.packages.build(package)
package.package_type = package['fullname'] =~ /.*\.src\.rpm$/ ? 'source' : 'binary'
package.project_id = bl.project_id
package.platform_id = bl.save_to_platform_id
package.save!
end
container = (options['results'] || []).
select{ |r| r['file_name'] !~ /.*\.log$/ }.first
sha1 = container ? container['sha1'] : nil
bl.results = options['results']
bl.save
bl.container_path = "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" if sha1
bl.save!
end
end