Class: Perkins::BuildReport
- Defined in:
- lib/perkins/build_report.rb
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#build_status_report(sha) ⇒ Object
Status report to GITHUB repo.
- #commit ⇒ Object
- #github_state ⇒ Object
- #github_state_description ⇒ Object
- #github_state_url ⇒ Object
- #send_github_status(sha) ⇒ Object
Instance Method Details
#as_json(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/perkins/build_report.rb', line 15 def as_json( = {}) data = {} unless fields = [:only] fields = [:id, :sha, :commit, :branch, :build_time, :status, :duration, :build_time, :response] end fields.each { |k| data[k] = send(k) } data end |
#build_status_report(sha) ⇒ Object
Status report to GITHUB repo
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/perkins/build_report.rb', line 32 def build_status_report(sha) $github_client.create_status( self.repo.name, sha, github_state, { context: "Perkins CI", description: github_state_description , target_url: github_state_url } ) end |
#commit ⇒ Object
5 6 7 8 |
# File 'lib/perkins/build_report.rb', line 5 def commit self.repo.load_git @commit ||= Perkins::Commit.new(self.sha, self.repo) end |
#github_state ⇒ Object
43 44 45 |
# File 'lib/perkins/build_report.rb', line 43 def github_state self.status ? "success" : "failure" end |
#github_state_description ⇒ Object
47 48 49 50 |
# File 'lib/perkins/build_report.rb', line 47 def github_state_description d = "- The Perkins CI build" d = self.status ? "passed" : "fail" end |
#github_state_url ⇒ Object
52 53 54 |
# File 'lib/perkins/build_report.rb', line 52 def github_state_url "#{Perkins::Application.instance.sse_endpoint}/repos/#{repo.name}/builds/#{self.id}" end |
#send_github_status(sha) ⇒ Object
10 11 12 13 |
# File 'lib/perkins/build_report.rb', line 10 def send_github_status(sha) self.repo.git self.build_status_report(sha) end |