Sha256: 610b0727fda8ce47de35a6d1ab785161902af258345d56f1c71d1956ed00fb9b
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
module Evrone module CI class Router module Middleware UpdateBuildStatus = Struct.new(:app) do include Helper::Logger STARTED = 2 FINISHED = 3 BROKEN = 4 FAILED = 5 def call(env) update_status env.build, 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.build, FINISHED when rs > 0 update_status env.build, BROKEN when rs < 0 update_status env.build, FAILED end rs end private def update_status(build, status) publish_status create_message(build, status), status end def create_message(build, status) tm = Time.now attributes = { build_id: build.message.id, status: status, tm: tm.to_i, tm_usec: tm.usec, matrix: build.matrix || [], jobs_count: build.jobs_count || 0, } if build.commit_info attributes.merge!( commit_author: build.commit_info.author, commit_author_email: build.commit_info.email, commit_sha: build.commit_info.sha, commit_message: build.commit_info.message ) end Message::BuildStatus.new attributes end def publish_status(message, status) logger.info "delivered build status #{message.inspect}" BuildStatusConsumer.publish message end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
evrone-ci-router-0.2.0.pre0 | lib/evrone/ci/router/middleware/update_build_status.rb |