Class: CodeBuildNotifier::BuildHistory

Inherits:
DynamoBase
  • Object
show all
Defined in:
lib/codebuild-notifier/build_history.rb

Instance Attribute Summary

Attributes inherited from DynamoBase

#config, #current_build

Instance Method Summary collapse

Methods inherited from DynamoBase

#initialize

Constructor Details

This class inherits a constructor from CodeBuildNotifier::DynamoBase

Instance Method Details

#last_entryObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/codebuild-notifier/build_history.rb', line 22

def last_entry
  return @last_entry if defined?(@last_entry)
  # If this build was launched using the Retry command from the console
  # or api we don't have a Pull Request or branch name to use in the
  # primary key, so we query by commit hash and project instead.
  item = launched_by_retry? ? find_by_commit : find_by_id

  # Provide .dot access to hash values from Dynamo item.
  @last_entry = item && Hashie::Mash.new(item)
end

#write_entry(source_id) {|updates| ... } ⇒ Object

Yields:

  • (updates)


33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/codebuild-notifier/build_history.rb', line 33

def write_entry(source_id)
  updates = hash_to_dynamo_update(new_entry).merge(
    key: { source_id: source_id, version_key: version_key }
  )

  yield updates if block_given?

  update_item(updates)

  ProjectSummary.new(config, current_build).update
  BranchEntry.new(config, current_build).update
end