Class: CIRunner::Client::AuthenticatedBuildkite

Inherits:
Base
  • Object
show all
Defined in:
lib/ci_runner/client/authenticated_buildkite.rb

Overview

Client used to retrieve private Resources on buildkite.

For public resources, the API can be used but only a limited number of users will be be able to access it as it requires a token scoped for the organization (most users working on opensource project aren’t member of the organization they contribute to).

Constant Summary collapse

API_ENDPOINT =
"api.buildkite.com"

Instance Method Summary collapse

Methods inherited from Base

default_client, #initialize, #reset!

Constructor Details

This class inherits a constructor from CIRunner::Client::Base

Instance Method Details

#access_tokenHash

Get information about an access token. Used to check if the token has the correct scopes.

Returns:

  • (Hash)

    See Buildkite doc

See Also:



51
52
53
# File 'lib/ci_runner/client/authenticated_buildkite.rb', line 51

def access_token
  get("/v2/access-token")
end

#download_log(url) ⇒ StringIO

Parameters:

  • url (String)

    A URL pointing to a log output resource.

Returns:

  • (StringIO)

See Also:



42
43
44
# File 'lib/ci_runner/client/authenticated_buildkite.rb', line 42

def download_log(url)
  StringIO.new(get(url))
end

#job_logs(org, pipeline, number) ⇒ Array<String>

Retrieve URLs to download job logs for all steps.

Parameters:

  • org (String)

    The organizatio name.

  • pipeline (String)

    The pipeline name.

  • number (Integer)

    The build number.

Returns:

  • (Array<String>)

    An array of URLs

See Also:



29
30
31
32
33
34
35
# File 'lib/ci_runner/client/authenticated_buildkite.rb', line 29

def job_logs(org, pipeline, number)
  build = get("/v2/organizations/#{org}/pipelines/#{pipeline}/builds/#{number}")

  build["jobs"].map do |job|
    job["raw_log_url"]
  end
end