2012-11-26 18:00:29 +00:00
|
|
|
module AbfWorker
|
2012-12-11 15:25:25 +00:00
|
|
|
class RpmWorkerObserver < AbfWorker::BaseObserver
|
2012-11-26 18:00:29 +00:00
|
|
|
@queue = :rpm_worker_observer
|
|
|
|
|
|
|
|
def self.perform(options)
|
|
|
|
bl = BuildList.find options['id']
|
2012-11-27 14:22:17 +00:00
|
|
|
status = options['status'].to_i
|
2012-12-03 17:17:20 +00:00
|
|
|
item = find_or_create_item(bl)
|
2012-11-27 14:22:17 +00:00
|
|
|
case status
|
2012-12-06 15:22:27 +00:00
|
|
|
when BUILD_COMPLETED
|
2012-11-26 18:00:29 +00:00
|
|
|
bl.build_success
|
2012-12-03 17:17:20 +00:00
|
|
|
item.update_attributes({:status => BuildServer::SUCCESS})
|
2012-12-06 15:22:27 +00:00
|
|
|
when BUILD_FAILED
|
2012-11-26 18:00:29 +00:00
|
|
|
bl.build_error
|
2012-12-03 17:17:20 +00:00
|
|
|
item.update_attributes({:status => BuildServer::BUILD_ERROR})
|
2012-12-06 15:22:27 +00:00
|
|
|
when BUILD_STARTED
|
2012-11-27 14:22:17 +00:00
|
|
|
bl.bs_id = bl.id
|
2012-12-03 17:17:20 +00:00
|
|
|
bl.save!
|
2012-11-26 18:00:29 +00:00
|
|
|
bl.start_build
|
2012-12-06 15:22:27 +00:00
|
|
|
when BUILD_CANCELED
|
2012-12-06 17:34:09 +00:00
|
|
|
bl.build_canceled
|
2012-12-06 16:28:44 +00:00
|
|
|
item.update_attributes({:status => BuildList::BUILD_CANCELED})
|
2012-11-26 18:00:29 +00:00
|
|
|
end
|
2012-12-06 15:22:27 +00:00
|
|
|
if status != BUILD_STARTED
|
2012-12-03 17:17:20 +00:00
|
|
|
fill_container_data bl, options
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class << self
|
|
|
|
protected
|
|
|
|
|
|
|
|
def find_or_create_item(bl)
|
|
|
|
bl.items.first || bl.items.create({
|
2012-12-04 15:48:30 +00:00
|
|
|
:version => bl.commit_hash,
|
2012-12-03 17:17:20 +00:00
|
|
|
: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
|
2012-12-11 11:47:32 +00:00
|
|
|
if sha1
|
|
|
|
bl.container_path = "#{APP_CONFIG['file_store_url']}/#{sha1}"
|
|
|
|
bl.save!
|
|
|
|
end
|
|
|
|
update_results(bl, options)
|
2012-11-27 14:22:17 +00:00
|
|
|
end
|
2012-11-26 18:00:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|