Class: CIRunner::Check::Buildkite

Inherits:
Base
  • Object
show all
Includes:
ConcurrentDownload
Defined in:
lib/ci_runner/check/buildkite.rb

Overview

Check class used when a project is configured to run its CI using Buildkite.

Instance Attribute Summary collapse

Attributes inherited from Base

#commit, #name, #repository, #status

Instance Method Summary collapse

Methods inherited from Base

#failed?, #success?

Constructor Details

#initialize(*args, url) ⇒ Buildkite

Returns a new instance of Buildkite.

Parameters:

  • args (See Base#initialize)
  • url (String)

    The html URL pointing to the Buildkite build.



16
17
18
19
20
# File 'lib/ci_runner/check/buildkite.rb', line 16

def initialize(*args, url)
  super(*args)

  @url = url
end

Instance Attribute Details

#urlObject (readonly)

:private:



12
13
14
# File 'lib/ci_runner/check/buildkite.rb', line 12

def url
  @url
end

Instance Method Details

#download_logTempfile

Download the CI logs for this Buildkite build.

The Buildkite API scopes tokens per organizations (token generated for org A can’t access resource on org B, even for public resources). This means that for opensource projects using Buildkite, users that are not members of the buildkite org normally can’t use CI Runner.

To bypass this problem, for builds that are public, CI Runner uses a different API. For private build, CI runner will check if the user had stored a Buildkite token in its config.

Returns:

  • (Tempfile)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ci_runner/check/buildkite.rb', line 39

def download_log
  uri = URI(url)
  _, org, pipeline, _, build = uri.path.split("/")
  @client = Client::Buildkite.new

  unless @client.public_build?(org, pipeline, build)
    token = retrieve_token_from_config(org, url)
    @client = Client::AuthenticatedBuildkite.new(token)
  end

  @client.job_logs(org, pipeline, build).each do |log_url|
    @queue << log_url
  end

  process_queue
end

#providerString

Used to tell the user which CI provider we are downloading the log output from.

Returns:

  • (String)


25
26
27
# File 'lib/ci_runner/check/buildkite.rb', line 25

def provider
  "Buildkite"
end