From b62414ec1da340aa707d956fc2092f31a57c17c2 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 10 Dec 2012 22:04:33 +0400 Subject: [PATCH] #755: update BuildList#publish_container --- app/models/build_list.rb | 23 +++++++--- .../publish_build_list_container_helper.rb | 43 ------------------- 2 files changed, 18 insertions(+), 48 deletions(-) delete mode 100644 lib/abf_worker/helpers/publish_build_list_container_helper.rb diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 65c740ec9..2fb4c8fae 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -144,6 +144,8 @@ class BuildList < ActiveRecord::Base after_transition :on => :published, :do => [:set_version_and_tag, :actualize_packages] after_transition :on => :cancel, :do => [:cancel_job], :if => lambda { |build_list| build_list.new_core? } + after_transition :on => :publish, :do => [:publish_container], + :if => lambda { |build_list| build_list.new_core? } after_transition :on => [:published, :fail_publish, :build_error], :do => :notify_users after_transition :on => :build_success, :do => :notify_users, @@ -201,7 +203,10 @@ class BuildList < ActiveRecord::Base event :publish do transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list| - BuildServer.publish_container(build_list.bs_id) == BuildServer::SUCCESS + !build_list.new_core? && BuildServer.publish_container(build_list.bs_id) == BuildServer::SUCCESS + } + transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list| + build_list.new_core? } transition [:success, :failed_publish] => :failed_publish end @@ -261,12 +266,20 @@ class BuildList < ActiveRecord::Base def publish_container type = save_to_platform.distrib_type + archive = results.select{ |r| r['file_name'] =~ /.*\.tar\.gz$/}[0] Resque.push( - "publish_build_list_container_#{type}", - 'class' => "AbfWorker::PublishBuildListContainer#{type.capitalize}", - 'args' => [{:id => id}] + "publish_build_list_container_#{type}_worker", + 'class' => "AbfWorker::PublishBuildListContainer#{type.capitalize}Worker", + 'args' => [{ + :id => id, + :released => save_to_platform.released, + :arch => arch.name, + :distrib_type => type, + :container_sha1 => archive['sha1'], + :platform_path => "#{APP_CONFIG[root]}/platforms/#{save_to_platform.name}/", + :time_living => 1800 # 30 min + }] ) - true end def add_to_queue diff --git a/lib/abf_worker/helpers/publish_build_list_container_helper.rb b/lib/abf_worker/helpers/publish_build_list_container_helper.rb deleted file mode 100644 index 98a36f595..000000000 --- a/lib/abf_worker/helpers/publish_build_list_container_helper.rb +++ /dev/null @@ -1,43 +0,0 @@ -module AbfWorker - module Helpers - module PublishBuildListContainerHelper - - def perform(options) - initialize_worker BuildList.find(options['id']) - publish - end - - private - - def publish - @build_list.packages.each do |package| - pdir_srpm = @platsdir + "/" + pname + "/repository/" + bpname + "/SRPMS/" + repo + "/" + version - pdir_rpm = @platsdir + "/" + pname + "/repository/" + bpname + "/" + arch + "/" + repo + "/" + version - end - end - - def initialize_worker(id) - @build_list = BuildList.find(id) - save_to_platform = @build_list.save_to_platform - @plid = save_to_platform.id - @pname = save_to_platform.name - @version = save_to_platform.released ? 'updates' : 'release' - - # TODO: where I can find it??? - @platsdir = "#{APP_CONFIG[root]}/platforms" - @arch = @build_list.arch.name - # TODO: what is it??? - only_newer = res[0]["only_newer"] - - build_for_platform = @build_list.build_for_platform - @idbuild_platform = build_for_platform.id - @bpname = build_for_platform.name - - @blname = "#{@build_list.items.first.name}-#{@build_list.bs_id}" - @bprid = @build_list.project_id - @bprname = @build_list.project.name - end - - end - end -end \ No newline at end of file