require 'evrone/ci/message' require 'evrone/ci/common' module Evrone module CI class Router class Build include Router::Helper::Logger include Router::Helper::Config attr_reader :message, :output attr_accessor :matrix, :jobs_count, :commit_info def initialize(perform_build_message) @output = '' @message = perform_build_message end def to_perform_job_message(travis, job_id) queue = travis.to_queue job_message = Message::PerformJob.new( id: message.id, name: message.name, src: message.src, sha: message.sha, pull_request_id: message.pull_request_id, deploy_key: message.deploy_key, job_id: job_id, before_script: queue.to_before_script, script: queue.to_script, matrix_keys: travis.matrix_keys, ) job_message end def add_to_output(str) output << str logger.debug str.strip if logger.level == 0 BuildLogsConsumer.publish create_build_log_message(str) end def add_command_to_output(cmd) add_to_output "$ #{cmd}\n" end def create_build_log_message(data) tm = Time.now Message::BuildLog.new( build_id: message.id, tm: tm.to_i, tm_usec: tm.usec, log: data ) end end end end end