Class: Bob::Builder

Inherits:
Object show all
Defined in:
lib/bob/builder.rb

Overview

A Builder will take care of building a buildable (wow, you didn’t see that coming, right?).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buildable, commit_id) ⇒ Builder

Instantiate the Builder, passing an object that understands the Buildable interface, and a commit_id.

You can pass :head as the commit id, in which case it will resolve to the head commit of the current branch (for example, “HEAD” under git, or the latest revision under svn)



13
14
15
16
# File 'lib/bob/builder.rb', line 13

def initialize(buildable, commit_id)
  @buildable = buildable
  @commit_id = commit_id
end

Instance Attribute Details

#buildableObject (readonly)

Returns the value of attribute buildable.



5
6
7
# File 'lib/bob/builder.rb', line 5

def buildable
  @buildable
end

Instance Method Details

#buildObject

This is where the magic happens:

  1. Check out the repo to the appropriate commit.

  2. Notify the buildable that the build is starting.

  3. Run the build script on it in the background.

  4. Reports the build back to the buildable.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bob/builder.rb', line 24

def build
  Bob.logger.info "Building #{commit_id} of the #{buildable.scm} repo at #{buildable.uri}"

  in_background do
    scm.with_commit(commit_id) {
      buildable.start_building(commit_id, scm.info(commit_id))
      build_status, build_output = run_build_script
      buildable.finish_building(commit_id, build_status, build_output)
    }
  end
end