lib/evrone/ci/router.rb in evrone-ci-router-0.2.0.pre6 vs lib/evrone/ci/router.rb in evrone-ci-router-0.2.0.pre7

- old
+ new

@@ -4,10 +4,12 @@ require 'thread' require 'bundler' Bundler.require :default +require 'evrone/ci/common/error_notifier' + require File.expand_path("../..", __FILE__) + "/ci/router/ext/string.rb" require File.expand_path("../..", __FILE__) + "/ci/router/ext/array.rb" module Evrone module CI @@ -22,10 +24,11 @@ autoload :BuildLogsConsumer, File.expand_path("../router/consumers/build_logs_consumer", __FILE__) autoload :BuildStatusConsumer, File.expand_path("../router/consumers/build_status_consumer", __FILE__) autoload :BuildsConsumer, File.expand_path("../router/consumers/builds_consumer", __FILE__) autoload :JobsConsumer, File.expand_path("../router/consumers/jobs_consumer", __FILE__) + autoload :JobStatusConsumer, File.expand_path("../router/consumers/job_status_consumer", __FILE__) module Helper autoload :Config, File.expand_path("../router/helper/config", __FILE__) autoload :Logger, File.expand_path("../router/helper/logger", __FILE__) autoload :TraceShCommand, File.expand_path("../router/helper/trace_sh_command", __FILE__) @@ -94,10 +97,12 @@ matrix.travises.each_with_index do |travis, idx| number = idx + 1 message = build.to_perform_job_message travis, number logger.info "delivery job #{message.id}.#{number} #{travis.to_matrix_s}" JobsConsumer.publish message + + publish_job_status_message build, travis, number end true end @@ -105,11 +110,11 @@ @travis = Travis.from_yaml build.message.travis @travis end def log_build - logger.tagged("BUILD #{build.message.id}") do + logger.tagged("build #{build.message.id}") do logger.info "starting build" rs = yield logger.info "done build" rs end @@ -120,10 +125,11 @@ rs = false begin rs = yield rescue Exception => e logger.error("ERROR: #{e.inspect}\n BACKTRACE:\n#{e.backtrace.map{|i| " #{i}" }.join("\n")}") + Common::ErrorNotifier.notify(e) end if rs publish_build_status_message Build::FINISHED else @@ -136,9 +142,21 @@ def publish_build_status_message(status) message = build.to_build_status_message(status) logger.info "delivered build status #{message.inspect}" BuildStatusConsumer.publish message + end + + def publish_job_status_message(build, travis, job_number) + message = Message::JobStatus.new( + build_id: build.message.id, + job_id: job_number, + status: Build::INITIALIED, + tm: Time.now.to_i, + matrix: travis.matrix_keys + ) + logger.info "delivery job status #{message.inspect}" + JobStatusConsumer.publish message end end end end