buildkite-builder 3.6.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/buildkite/builder/extension.rb +0 -10
- data/lib/buildkite/pipelines.rb +0 -1
- metadata +3 -4
- data/lib/buildkite/pipelines/api.rb +0 -119
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3804d4ee1257c87c370c1be4bf744c531521294c24a19eb48c87f55277e88754
|
4
|
+
data.tar.gz: a7d49a4058d7873669aae486848be13ec8a84af758df0f74bf44560fcd686e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7d55f1b56b362778809522dc3d7c42567b19a89192074fd72c9b20261ab7d061e0f3498943f02082548bdb7bd41ae98db485bc09a335938675be2c78491a177
|
7
|
+
data.tar.gz: e72473fbeb58287e8c2ec898490666777b54bb7e496faad5f80cc0c923d8bece96891ec6921342bb09191eef50a3a798185db6e710cd3169e507b70dff443836
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.7.0
|
@@ -32,16 +32,6 @@ module Buildkite
|
|
32
32
|
context.logger
|
33
33
|
end
|
34
34
|
|
35
|
-
def buildkite
|
36
|
-
@buildkite ||= begin
|
37
|
-
unless Buildkite.env
|
38
|
-
raise 'Must be in Buildkite environment to access the Buildkite API'
|
39
|
-
end
|
40
|
-
|
41
|
-
Buildkite::Pipelines::Api.new(Buildkite.env.api_token)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
35
|
def prepare
|
46
36
|
# Override to provide extra functionality.
|
47
37
|
end
|
data/lib/buildkite/pipelines.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Buildkite
|
4
4
|
module Pipelines
|
5
|
-
autoload :Api, File.expand_path('pipelines/api', __dir__)
|
6
5
|
autoload :Attributes, File.expand_path('pipelines/attributes', __dir__)
|
7
6
|
autoload :Command, File.expand_path('pipelines/command', __dir__)
|
8
7
|
autoload :Helpers, File.expand_path('pipelines/helpers', __dir__)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkite-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ngan Pham
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -132,7 +132,6 @@ files:
|
|
132
132
|
- lib/buildkite/builder/template_manager.rb
|
133
133
|
- lib/buildkite/env.rb
|
134
134
|
- lib/buildkite/pipelines.rb
|
135
|
-
- lib/buildkite/pipelines/api.rb
|
136
135
|
- lib/buildkite/pipelines/attributes.rb
|
137
136
|
- lib/buildkite/pipelines/command.rb
|
138
137
|
- lib/buildkite/pipelines/helpers.rb
|
@@ -178,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
177
|
- !ruby/object:Gem::Version
|
179
178
|
version: '0'
|
180
179
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
180
|
+
rubygems_version: 3.3.7
|
182
181
|
signing_key:
|
183
182
|
specification_version: 4
|
184
183
|
summary: A gem for programmatically creating Buildkite pipelines.
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
require 'net/http'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
module Buildkite
|
8
|
-
module Pipelines
|
9
|
-
class Api
|
10
|
-
BASE_URI = URI('https://api.buildkite.com/v2').freeze
|
11
|
-
URI_PARTS = {
|
12
|
-
organization: 'organizations',
|
13
|
-
pipeline: 'pipelines',
|
14
|
-
pipelines: 'pipelines',
|
15
|
-
build: 'builds',
|
16
|
-
builds: 'builds',
|
17
|
-
access_token: 'access-token',
|
18
|
-
}.freeze
|
19
|
-
|
20
|
-
def initialize(token)
|
21
|
-
@token = token
|
22
|
-
end
|
23
|
-
|
24
|
-
def get_access_token
|
25
|
-
uri = uri_for(access_token: nil)
|
26
|
-
JSON.parse(get_request(uri).body)
|
27
|
-
end
|
28
|
-
|
29
|
-
def list_pipelines(organization)
|
30
|
-
raise NotImplementedError
|
31
|
-
end
|
32
|
-
|
33
|
-
def get_pipeline(organization, pipeline)
|
34
|
-
response = get_request(
|
35
|
-
uri_for(
|
36
|
-
organization: organization,
|
37
|
-
pipeline: pipeline
|
38
|
-
)
|
39
|
-
)
|
40
|
-
if response.is_a?(Net::HTTPSuccess)
|
41
|
-
JSON.parse(response.body)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def create_pipeline(organization, params)
|
46
|
-
uri = uri_for(
|
47
|
-
organization: organization,
|
48
|
-
pipelines: nil
|
49
|
-
)
|
50
|
-
JSON.parse(post_request(uri, params).body)
|
51
|
-
end
|
52
|
-
|
53
|
-
def get_pipeline_builds(organization, pipeline, **params)
|
54
|
-
uri = uri_for(params.merge(
|
55
|
-
organization: organization,
|
56
|
-
pipeline: pipeline,
|
57
|
-
builds: nil
|
58
|
-
))
|
59
|
-
JSON.parse(get_request(uri).body)
|
60
|
-
end
|
61
|
-
|
62
|
-
def get_build(organization, pipeline, build)
|
63
|
-
uri = uri_for(
|
64
|
-
organization: organization,
|
65
|
-
pipeline: pipeline,
|
66
|
-
build: build
|
67
|
-
)
|
68
|
-
JSON.parse(get_request(uri).body)
|
69
|
-
end
|
70
|
-
|
71
|
-
def create_build(organization, pipeline)
|
72
|
-
raise NotImplementedError
|
73
|
-
end
|
74
|
-
|
75
|
-
def cancel_build(organization, pipeline, build)
|
76
|
-
raise NotImplementedError
|
77
|
-
end
|
78
|
-
|
79
|
-
def rebuild_build(organization, pipeline, build)
|
80
|
-
raise NotImplementedError
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def get_request(uri)
|
86
|
-
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
87
|
-
request = prepare_request(Net::HTTP::Get.new(uri))
|
88
|
-
http.request(request)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def post_request(uri, data)
|
93
|
-
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
94
|
-
request = prepare_request(Net::HTTP::Post.new(uri))
|
95
|
-
request.content_type = 'application/json'
|
96
|
-
request.body = data.to_json
|
97
|
-
http.request(request)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def uri_for(options)
|
102
|
-
uri_parts = URI_PARTS.each_with_object([]) do |(resource, path), parts|
|
103
|
-
if options.key?(resource)
|
104
|
-
parts << [path, options.delete(resource)].compact
|
105
|
-
end
|
106
|
-
end
|
107
|
-
uri = URI(uri_parts.flatten.unshift(BASE_URI).join('/'))
|
108
|
-
uri.query = URI.encode_www_form(options) if options.any?
|
109
|
-
uri
|
110
|
-
end
|
111
|
-
|
112
|
-
def prepare_request(request)
|
113
|
-
request['Authorization'] = "Bearer #{@token}"
|
114
|
-
request['Accept'] = 'application/json'
|
115
|
-
request
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|