buildkit 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d162a0a598036a70a22e5e46e3a71cf6f0b00f6e
4
- data.tar.gz: bffdf975b211b039d78e2d8d1995fd25acddd153
3
+ metadata.gz: 64e7a9271c0e2d717b54e94d2376bcbe9d2b0874
4
+ data.tar.gz: 74bcd8f4013c4e67bc898047b277dd05632f2ff0
5
5
  SHA512:
6
- metadata.gz: a704cd607dc9c306626f24e7f47cb1854d658153755146d926a12185a00101129e088f7e712a0713fce79660311dc6909370906ea04f43aeedd95665ad925eb2
7
- data.tar.gz: 5df600fb07dbbf3b468d4ade3390c7600e0949ed7322cff18ae40ba8f4be8ef29a0301760fad6e77c3169b58ad9c312a8c98ab1ae1bf869f83ca118ecb590c81
6
+ metadata.gz: 85841d9c8a376d667c05a32cf805ede8e078f1b4056d20e07069354f132d155a0e9df10d0ec62f790974120c6d556aeae75c94617b8745044d7105d4fee13789
7
+ data.tar.gz: 2df8497a6f244a38fa314886ecbeae14c2a7b3033daba366495fde6e875e523b33854eeb30c2d15227c3f44daffd06cd5f9456e8275be41dadd465a8e48010ea
@@ -9,6 +9,9 @@ Metrics/LineLength:
9
9
  Metrics/MethodLength:
10
10
  Max: 25
11
11
 
12
+ Metrics/BlockLength:
13
+ Enabled: false # RSpec ... :facepalm:
14
+
12
15
  Metrics/AbcSize:
13
16
  Max: 30
14
17
 
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rake'
4
3
  gem 'byebug'
4
+ gem 'rake'
5
5
  gem 'rubocop'
6
6
  gem 'yard'
7
7
 
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.0'
22
22
 
23
- spec.add_dependency 'sawyer', '~> 0.6.0'
23
+ spec.add_dependency 'sawyer', '~> 0.6'
24
24
  spec.add_development_dependency 'bundler'
25
25
  end
@@ -3,6 +3,8 @@ require 'buildkit/client/agents'
3
3
  require 'buildkit/client/builds'
4
4
  require 'buildkit/client/organizations'
5
5
  require 'buildkit/client/pipelines'
6
+ require 'buildkit/client/jobs'
7
+ require 'buildkit/client/artifacts'
6
8
  require 'buildkit/response/raise_error'
7
9
 
8
10
  module Buildkit
@@ -11,6 +13,8 @@ module Buildkit
11
13
  include Builds
12
14
  include Organizations
13
15
  include Pipelines
16
+ include Jobs
17
+ include Artifacts
14
18
 
15
19
  DEFAULT_ENDPOINT = 'https://api.buildkite.com/v2/'.freeze
16
20
 
@@ -20,14 +24,20 @@ module Buildkit
20
24
  # In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder
21
25
  RACK_BUILDER_CLASS = defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
22
26
 
23
- # Default Faraday middleware stack
24
- MIDDLEWARE = RACK_BUILDER_CLASS.new do |builder|
25
- builder.use Buildkit::Response::RaiseError
26
- builder.adapter Faraday.default_adapter
27
+ class << self
28
+ def build_middleware
29
+ RACK_BUILDER_CLASS.new do |builder|
30
+ builder.use Buildkit::Response::RaiseError
31
+ builder.adapter Faraday.default_adapter
32
+ yield builder if block_given?
33
+ end
34
+ end
27
35
  end
28
36
 
29
37
  def initialize(endpoint: ENV.fetch('BUILDKITE_API_ENDPOINT', DEFAULT_ENDPOINT),
30
- token: ENV.fetch('BUILDKITE_API_TOKEN'))
38
+ token: ENV.fetch('BUILDKITE_API_TOKEN'),
39
+ middleware: self.class.build_middleware)
40
+ @middleware = middleware
31
41
  @endpoint = endpoint
32
42
  @token = token
33
43
  end
@@ -122,7 +132,7 @@ module Buildkit
122
132
  def sawyer_options
123
133
  {
124
134
  links_parser: Sawyer::LinkParsers::Simple.new,
125
- faraday: Faraday.new(builder: MIDDLEWARE),
135
+ faraday: Faraday.new(builder: @middleware),
126
136
  }
127
137
  end
128
138
 
@@ -0,0 +1,18 @@
1
+ module Buildkit
2
+ class Client
3
+ # Methods for the Artifacts API
4
+ #
5
+ # @see https://buildkite.com/docs/api/artifacts
6
+ module Artifacts
7
+ # List all artifacts for a build
8
+ #
9
+ # @return [Array<Sawyer::Resource>] Array of hashes representing Buildkite artifacts.
10
+ # @see https://buildkite.com/docs/api/artifacts#list-all-artifacts
11
+ # @example
12
+ # Buildkit.artifacts('my-great-org', 'great-pipeline', 42)
13
+ def artifacts(org, pipeline, build, options = {})
14
+ get("/v2/organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/artifacts", options)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,36 @@
1
+ module Buildkit
2
+ class Client
3
+ # Methods for the Jobs API
4
+ #
5
+ # @see https://buildkite.com/docs/rest-api/jobs
6
+ module Jobs
7
+ # Retry a job
8
+ #
9
+ # @param org [String] Organization slug.
10
+ # @param pipeline [String] Pipeline slug.
11
+ # @param build [Integer] Build number.
12
+ # @param job [String] Job id.
13
+ # @return [Array<Sawyer::Resource>] Hashes representing Buildkite job.
14
+ # @see https://buildkite.com/docs/rest-api/jobs#retry-a-job
15
+ # @example
16
+ # Buildkit.retry_job('my-great-org', 'great-pipeline', 123, 'my-job-id')
17
+ def retry_job(org, pipeline, build, job, options = {})
18
+ put("/v2/organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/retry", options)
19
+ end
20
+
21
+ # Get a job's environment variables
22
+ #
23
+ # @param org [String] Organization slug.
24
+ # @param pipeline [String] Pipeline slug.
25
+ # @param build [Integer] Build number.
26
+ # @param job [String] Job id.
27
+ # @return [Array<Sawyer::Resource>] Hashes representing Buildkite job env.
28
+ # @see https://buildkite.com/docs/rest-api/jobs#get-a-jobs-environment-variables
29
+ # @example
30
+ # Buildkit.job_env('my-great-org', 'great-pipeline', 123, 'my-job-id')
31
+ def job_env(org, pipeline, build, job, options = {})
32
+ get("/v2/organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/env", options)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -48,6 +48,21 @@ module Buildkit
48
48
  def create_pipeline(org, options = {})
49
49
  post("/v2/organizations/#{org}/pipelines", options)
50
50
  end
51
+
52
+ # Update a pipeline
53
+ #
54
+ # @param org [String] Organization slug.
55
+ # @param pipeline [String] pipeline slug.
56
+ # @return [Sawyer::Resource] Hash representing Buildkite pipeline
57
+ # @see https://buildkite.com/docs/api/pipelines#update-a-pipeline
58
+ # @example
59
+ # Buildkit.update_pipeline('my-great-org', 'great-pipeline', {
60
+ # name: 'My pipeline 2',
61
+ # })
62
+ #
63
+ def update_pipeline(org, pipeline, options = {})
64
+ patch("/v2/organizations/#{org}/pipelines/#{pipeline}", options)
65
+ end
51
66
  end
52
67
  end
53
68
  end
@@ -1,3 +1,3 @@
1
1
  module Buildkit
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sawyer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.0
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.0
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,7 +60,9 @@ files:
60
60
  - lib/buildkit.rb
61
61
  - lib/buildkit/client.rb
62
62
  - lib/buildkit/client/agents.rb
63
+ - lib/buildkit/client/artifacts.rb
63
64
  - lib/buildkit/client/builds.rb
65
+ - lib/buildkit/client/jobs.rb
64
66
  - lib/buildkit/client/organizations.rb
65
67
  - lib/buildkit/client/pipelines.rb
66
68
  - lib/buildkit/error.rb