rosa-build/lib/abf_worker/publish_observer.rb

56 lines
1.7 KiB
Ruby
Raw Normal View History

module AbfWorker
2012-12-29 10:48:19 +00:00
class PublishObserver < AbfWorker::BaseObserver
@queue = :publish_observer
2013-01-23 09:42:05 +00:00
def self.perform(options)
new(options, BuildList).perform
end
protected
def perform
2013-01-23 09:42:05 +00:00
return if status == STARTED # do nothing when publication started
if options['type'] == 'resign'
AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id']
else
2013-01-25 17:24:46 +00:00
if options['extra']['create_container'] # Container has been created
case status
when COMPLETED
subject.published_container
when FAILED, CANCELED
subject.fail_publish_container
end
update_results
2013-01-25 17:24:46 +00:00
else
update_rpm_builds
2013-01-25 17:24:46 +00:00
end
end
2013-01-23 09:42:05 +00:00
end
def update_rpm_builds
2013-01-23 09:42:05 +00:00
build_lists = BuildList.where(:id => options['build_list_ids'])
build_lists.each do |build_list|
update_results build_list
2013-01-23 09:42:05 +00:00
case status
when COMPLETED
build_list.published
2013-01-23 09:42:05 +00:00
AbfWorker::BuildListsPublishTaskManager.cleanup_completed options['projects_for_cleanup']
when FAILED, CANCELED
build_list.fail_publish
2013-01-23 09:42:05 +00:00
AbfWorker::BuildListsPublishTaskManager.cleanup_failed options['projects_for_cleanup']
end
AbfWorker::BuildListsPublishTaskManager.unlock_build_list build_list
end
build_list = build_lists.first || BuildList.find(options['id'])
AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform build_list
2013-01-23 09:42:05 +00:00
end
def update_results(build_list)
results = (build_list.results || []).
select{ |r| r['file_name'] !~ /^abfworker\:\:publish\-worker.*\.log$/ }
results |= options['results']
sort_results_and_save results, build_list
end
end
end