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 +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +1 -1
- data/buildkit.gemspec +1 -1
- data/lib/buildkit/client.rb +16 -6
- data/lib/buildkit/client/artifacts.rb +18 -0
- data/lib/buildkit/client/jobs.rb +36 -0
- data/lib/buildkit/client/pipelines.rb +15 -0
- data/lib/buildkit/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64e7a9271c0e2d717b54e94d2376bcbe9d2b0874
|
4
|
+
data.tar.gz: 74bcd8f4013c4e67bc898047b277dd05632f2ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85841d9c8a376d667c05a32cf805ede8e078f1b4056d20e07069354f132d155a0e9df10d0ec62f790974120c6d556aeae75c94617b8745044d7105d4fee13789
|
7
|
+
data.tar.gz: 2df8497a6f244a38fa314886ecbeae14c2a7b3033daba366495fde6e875e523b33854eeb30c2d15227c3f44daffd06cd5f9456e8275be41dadd465a8e48010ea
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/buildkit.gemspec
CHANGED
data/lib/buildkit/client.rb
CHANGED
@@ -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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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:
|
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
|
data/lib/buildkit/version.rb
CHANGED
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.
|
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-
|
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
|
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
|
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
|