Class: Buildbox::Agent

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Celluloid::Logger
Defined in:
lib/buildbox/agent.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_token, api = Buildbox::API.new) ⇒ Agent

Returns a new instance of Agent.



8
9
10
11
# File 'lib/buildbox/agent.rb', line 8

def initialize(access_token, api = Buildbox::API.new)
  @api           = api
  @access_token  = access_token
end

Instance Method Details

#processObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/buildbox/agent.rb', line 13

def process
  return if @current_build

  if @current_build = next_build
    @api.update_build(@access_token, @current_build, :agent_accepted => @access_token)

    montior = Monitor.new(@current_build, @access_token, @api).async.monitor
    runner  = Runner.start(@current_build)

    @current_build.artifact_paths.each do |path|
      upload_artifacts_from(runner.build_directory, path)
    end
  end

  @current_build = nil
end