Sha256: 5cd5ab6eb57db7a3c3a5e2f26c6f59ea97b9cab5cb8efa475cac66f8744e746c
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require 'evrone/ci/message' module Evrone module CI module Worker UpdateJobStatus = Struct.new(:app) do include Helper::Logger STARTED = 2 FINISHED = 3 BROKEN = 4 FAILED = 5 def call(env) update_status env.job, STARTED rs = -1 begin rs = app.call env rescue Exception => e logger.error("ERROR: #{e.inspect}\n BACKTRACE:\n#{e.backtrace.map{|i| " #{i}" }.join("\n")}") end case when rs == 0 update_status env.job, FINISHED when rs > 0 update_status env.job, BROKEN when rs < 0 update_status env.job, FAILED end rs end private def update_status(job, status) publish_status create_message(job, status) end def create_message(job, status) tm = Time.now Message::JobStatus.new( build_id: job.message.id, job_id: job.message.job_id, status: status, tm: tm.to_i, tm_usec: tm.usec, matrix: job.message.matrix_keys ) end def publish_status(message) logger.info "delivered job status #{message.inspect}" JobStatusConsumer.publish message end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
evrone-ci-worker-0.2.0.pre1 | lib/evrone/ci/worker/middlewares/update_job_status.rb |
evrone-ci-worker-0.2.0.pre0 | lib/evrone/ci/worker/middlewares/update_job_status.rb |