2012-12-10 17:01:34 +00:00
|
|
|
module AbfWorker
|
2012-12-29 10:48:19 +00:00
|
|
|
class PublishObserver < AbfWorker::BaseObserver
|
|
|
|
@queue = :publish_observer
|
2012-12-10 17:01:34 +00:00
|
|
|
|
2013-01-17 14:15:03 +00:00
|
|
|
|
2013-01-23 09:42:05 +00:00
|
|
|
def self.perform(options)
|
2013-02-05 18:49:26 +00:00
|
|
|
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
|
2013-01-28 14:44:06 +00:00
|
|
|
case status
|
|
|
|
when COMPLETED
|
2013-02-05 18:49:26 +00:00
|
|
|
subject.published_container
|
2013-01-28 14:44:06 +00:00
|
|
|
when FAILED, CANCELED
|
2013-02-05 18:49:26 +00:00
|
|
|
subject.fail_publish_container
|
2013-01-28 14:44:06 +00:00
|
|
|
end
|
2013-02-05 18:49:26 +00:00
|
|
|
update_results
|
2013-01-25 17:24:46 +00:00
|
|
|
else
|
2013-02-05 18:49:26 +00:00
|
|
|
update_rpm_builds
|
2013-01-25 17:24:46 +00:00
|
|
|
end
|
2012-12-11 10:42:15 +00:00
|
|
|
end
|
2013-01-23 09:42:05 +00:00
|
|
|
end
|
2012-12-11 10:42:15 +00:00
|
|
|
|
2013-02-05 18:49:26 +00:00
|
|
|
def update_rpm_builds
|
2013-01-23 09:42:05 +00:00
|
|
|
build_lists = BuildList.where(:id => options['build_list_ids'])
|
2013-02-05 18:49:26 +00:00
|
|
|
build_lists.each do |build_list|
|
|
|
|
update_results build_list
|
2013-01-23 09:42:05 +00:00
|
|
|
case status
|
|
|
|
when COMPLETED
|
2013-02-05 18:49:26 +00:00
|
|
|
build_list.published
|
2013-01-23 09:42:05 +00:00
|
|
|
AbfWorker::BuildListsPublishTaskManager.cleanup_completed options['projects_for_cleanup']
|
|
|
|
when FAILED, CANCELED
|
2013-02-05 18:49:26 +00:00
|
|
|
build_list.fail_publish
|
2013-01-23 09:42:05 +00:00
|
|
|
AbfWorker::BuildListsPublishTaskManager.cleanup_failed options['projects_for_cleanup']
|
2013-01-17 14:15:03 +00:00
|
|
|
end
|
2013-02-05 18:49:26 +00:00
|
|
|
AbfWorker::BuildListsPublishTaskManager.unlock_build_list build_list
|
2013-01-17 14:15:03 +00:00
|
|
|
end
|
2013-02-05 18:49:26 +00:00
|
|
|
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
|
|
|
|
|
2013-02-05 18:49:26 +00:00
|
|
|
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
|
2012-12-12 12:32:47 +00:00
|
|
|
end
|
2012-12-10 17:01:34 +00:00
|
|
|
end
|
|
|
|
end
|