Class: Buildkite::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/buildkite/models/build.rb

Class Method Summary collapse

Methods inherited from Object

#initialize, #to_ostruct

Constructor Details

This class inherits a constructor from Buildkite::Object

Class Method Details

.cancel(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:) ⇒ Object



31
32
33
34
# File 'lib/buildkite/models/build.rb', line 31

def cancel(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:)
  response = Client.put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/cancel", body: {})
  Build.new response.body
end

.create(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, commit:, branch:, **args) ⇒ Object



25
26
27
28
29
# File 'lib/buildkite/models/build.rb', line 25

def create(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, commit:, branch:, **args)
  data = {commit: commit, branch: branch}
  response = Client.post_request("organizations/#{org}/pipelines/#{pipeline}/builds", body: data.merge(args))
  Build.new response.body
end

.list(org: nil, pipeline: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/buildkite/models/build.rb', line 6

def list(org: nil, pipeline: nil)
  if org && pipeline
    response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}/builds")
  elsif org
    response = Client.get_request("organizations/#{org}/builds")
  else
    response = Client.get_request("builds")
  end

  if response
    Collection.from_response(response, type: Build)
  end
end

.rebuild(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:) ⇒ Object



36
37
38
39
# File 'lib/buildkite/models/build.rb', line 36

def rebuild(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:)
  response = Client.put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/rebuild", body: {})
  Build.new response.body
end

.retrieve(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:) ⇒ Object



20
21
22
23
# File 'lib/buildkite/models/build.rb', line 20

def retrieve(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:)
  response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}")
  Build.new response.body
end