buildkiterb 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +2 -1
- data/.github/workflows/ci.yml +2 -2
- data/Gemfile +3 -1
- data/Gemfile.lock +4 -2
- data/README.md +110 -39
- data/bin/console +4 -1
- data/lib/buildkite/client.rb +52 -53
- data/lib/buildkite/configuration.rb +11 -0
- data/lib/buildkite/models/access_token.rb +18 -0
- data/lib/buildkite/models/agent.rb +23 -0
- data/lib/buildkite/models/annotation.rb +14 -0
- data/lib/buildkite/models/artifact.rb +33 -0
- data/lib/buildkite/models/build.rb +44 -0
- data/lib/buildkite/models/cluster.rb +34 -0
- data/lib/buildkite/models/cluster_queue.rb +44 -0
- data/lib/buildkite/models/cluster_token.rb +34 -0
- data/lib/buildkite/models/emoji.rb +14 -0
- data/lib/buildkite/models/job.rb +33 -0
- data/lib/buildkite/models/organization.rb +19 -0
- data/lib/buildkite/models/pipeline.rb +48 -0
- data/lib/buildkite/models/user.rb +14 -0
- data/lib/buildkite/version.rb +1 -1
- data/lib/buildkite.rb +32 -28
- metadata +24 -31
- data/lib/buildkite/objects/access_token.rb +0 -4
- data/lib/buildkite/objects/agent.rb +0 -4
- data/lib/buildkite/objects/annotation.rb +0 -4
- data/lib/buildkite/objects/artifact.rb +0 -4
- data/lib/buildkite/objects/build.rb +0 -4
- data/lib/buildkite/objects/emoji.rb +0 -4
- data/lib/buildkite/objects/job.rb +0 -4
- data/lib/buildkite/objects/organization.rb +0 -4
- data/lib/buildkite/objects/pipeline.rb +0 -4
- data/lib/buildkite/objects/user.rb +0 -4
- data/lib/buildkite/resource.rb +0 -59
- data/lib/buildkite/resources/access_token.rb +0 -13
- data/lib/buildkite/resources/agents.rb +0 -18
- data/lib/buildkite/resources/annotations.rb +0 -10
- data/lib/buildkite/resources/artifacts.rb +0 -27
- data/lib/buildkite/resources/builds.rb +0 -36
- data/lib/buildkite/resources/emojis.rb +0 -10
- data/lib/buildkite/resources/jobs.rb +0 -25
- data/lib/buildkite/resources/organizations.rb +0 -14
- data/lib/buildkite/resources/pipelines.rb +0 -39
- data/lib/buildkite/resources/user.rb +0 -9
- /data/lib/buildkite/{objects → models}/artifact_download.rb +0 -0
- /data/lib/buildkite/{objects → models}/job_env.rb +0 -0
- /data/lib/buildkite/{objects → models}/job_log.rb +0 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
module Buildkite
|
2
|
+
class ClusterQueue < Object
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def list(org: Buildkite.config.org, cluster:)
|
7
|
+
response = Client.get_request("organizations/#{org}/clusters/#{cluster}/queues")
|
8
|
+
Collection.from_response(response, type: ClusterQueue)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(org: Buildkite.config.org, cluster:, id:)
|
12
|
+
response = Client.get_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}")
|
13
|
+
ClusterQueue.new response.body
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(org: Buildkite.config.org, cluster:, key:, **args)
|
17
|
+
data = {key: key}
|
18
|
+
response = Client.post_request("organizations/#{org}/clusters/#{cluster}/queues", body: data.merge(args))
|
19
|
+
ClusterQueue.new response.body
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(org: Buildkite.config.org, cluster:, id:, **args)
|
23
|
+
response = Client.patch_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}", body: args)
|
24
|
+
ClusterQueue.new response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
def pause(org: Buildkite.config.org, cluster:, id:, note: nil)
|
28
|
+
response = Client.post_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}/pause_dispatch", body: {note: note})
|
29
|
+
ClusterQueue.new response.body
|
30
|
+
end
|
31
|
+
|
32
|
+
def resume(org: Buildkite.config.org, cluster:, id:)
|
33
|
+
response = Client.post_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}/resume_dispatch", body: {})
|
34
|
+
ClusterQueue.new response.body
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete(org: Buildkite.config.org, cluster:, id:)
|
38
|
+
Client.delete_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}")
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Buildkite
|
2
|
+
class ClusterToken < Object
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def list(org: Buildkite.config.org, cluster:)
|
7
|
+
response = Client.get_request("organizations/#{org}/clusters/#{cluster}/tokens")
|
8
|
+
Collection.from_response(response, type: ClusterToken)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(org: Buildkite.config.org, cluster:, id:)
|
12
|
+
response = Client.get_request("organizations/#{org}/clusters/#{cluster}/tokens/#{id}")
|
13
|
+
ClusterToken.new response.body
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(org: Buildkite.config.org, cluster:, description:, **args)
|
17
|
+
data = {description: description}
|
18
|
+
response = Client.post_request("organizations/#{org}/clusters/#{cluster}/tokens", body: data.merge(args))
|
19
|
+
ClusterToken.new response.body
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(org: Buildkite.config.org, cluster:, id:, **args)
|
23
|
+
response = Client.patch_request("organizations/#{org}/clusters/#{cluster}/tokens/#{id}", body: args)
|
24
|
+
ClusterToken.new response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete(org: Buildkite.config.org, cluster:, id:)
|
28
|
+
Client.delete_request("organizations/#{org}/clusters/#{cluster}/tokens/#{id}")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Buildkite
|
2
|
+
class Job < Object
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def retry(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
|
7
|
+
response = Client.put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/retry", body: {})
|
8
|
+
Job.new response.body
|
9
|
+
end
|
10
|
+
|
11
|
+
def unblock(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:, **args)
|
12
|
+
response = Client.put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/unblock", body: args)
|
13
|
+
Job.new response.body
|
14
|
+
end
|
15
|
+
|
16
|
+
def log(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
|
17
|
+
response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/log")
|
18
|
+
JobLog.new response.body
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_log(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
|
22
|
+
Client.delete_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/log")
|
23
|
+
end
|
24
|
+
|
25
|
+
def env(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
|
26
|
+
response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/env")
|
27
|
+
JobEnv.new response.body["env"]
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Buildkite
|
2
|
+
class Organization < Object
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def list
|
7
|
+
response = Client.get_request("organizations")
|
8
|
+
Collection.from_response(response, type: Organization)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(slug:)
|
12
|
+
response = Client.get_request("organizations/#{slug}")
|
13
|
+
Organization.new(response.body)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Buildkite
|
2
|
+
class Pipeline < Object
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def list(org: Buildkite.config.org)
|
7
|
+
response = Client.get_request("organizations/#{org}/pipelines")
|
8
|
+
Collection.from_response(response, type: Pipeline)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
|
12
|
+
response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}")
|
13
|
+
Pipeline.new response.body
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(org: Buildkite.config.org, name:, repository:, configuration:, **args)
|
17
|
+
data = {name: name, repository: repository, configuration: configuration}
|
18
|
+
response = Client.post_request("organizations/#{org}/pipelines", body: data.merge(args))
|
19
|
+
Pipeline.new response.body
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, **args)
|
23
|
+
response = Client.patch_request("organizations/#{org}/pipelines/#{pipeline}", body: args)
|
24
|
+
Pipeline.new response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
def archive(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
|
28
|
+
response = Client.post_request("organizations/#{org}/pipelines/#{pipeline}/archive", body: {})
|
29
|
+
Pipeline.new response.body
|
30
|
+
end
|
31
|
+
|
32
|
+
def unarchive(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
|
33
|
+
response = Client.post_request("organizations/#{org}/pipelines/#{pipeline}/unarchive", body: {})
|
34
|
+
Pipeline.new response.body
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
|
38
|
+
Client.delete_request("organizations/#{org}/pipelines/#{pipeline}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def webhook(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
|
42
|
+
Client.post_request("organizations/#{org}/pipelines/#{pipeline}/webhook", body: {})
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/buildkite/version.rb
CHANGED
data/lib/buildkite.rb
CHANGED
@@ -1,38 +1,42 @@
|
|
1
1
|
require "faraday"
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
require_relative "buildkite/version"
|
4
4
|
|
5
5
|
module Buildkite
|
6
6
|
|
7
|
+
autoload :Configuration, "buildkite/configuration"
|
7
8
|
autoload :Client, "buildkite/client"
|
8
9
|
autoload :Collection, "buildkite/collection"
|
9
10
|
autoload :Error, "buildkite/error"
|
10
|
-
autoload :Resource, "buildkite/resource"
|
11
11
|
autoload :Object, "buildkite/object"
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
autoload :
|
26
|
-
autoload :
|
27
|
-
autoload :
|
28
|
-
autoload :
|
29
|
-
autoload :
|
30
|
-
autoload :
|
31
|
-
autoload :
|
32
|
-
autoload :
|
33
|
-
autoload :
|
34
|
-
autoload :
|
35
|
-
autoload :
|
36
|
-
autoload :
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_writer :config
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
yield(config) if block_given?
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.config
|
22
|
+
@config ||= Buildkite::Configuration.new
|
23
|
+
end
|
24
|
+
|
25
|
+
autoload :AccessToken, "buildkite/models/access_token"
|
26
|
+
autoload :Organization, "buildkite/models/organization"
|
27
|
+
autoload :Pipeline, "buildkite/models/pipeline"
|
28
|
+
autoload :Build, "buildkite/models/build"
|
29
|
+
autoload :Job, "buildkite/models/job"
|
30
|
+
autoload :JobLog, "buildkite/models/job_log"
|
31
|
+
autoload :JobEnv, "buildkite/models/job_env"
|
32
|
+
autoload :Agent, "buildkite/models/agent"
|
33
|
+
autoload :Cluster, "buildkite/models/cluster"
|
34
|
+
autoload :ClusterQueue, "buildkite/models/cluster_queue"
|
35
|
+
autoload :ClusterToken, "buildkite/models/cluster_token"
|
36
|
+
autoload :Annotation, "buildkite/models/annotation"
|
37
|
+
autoload :Artifact, "buildkite/models/artifact"
|
38
|
+
autoload :ArtifactDownload, "buildkite/models/artifact_download"
|
39
|
+
autoload :Emoji, "buildkite/models/emoji"
|
40
|
+
autoload :User, "buildkite/models/user"
|
37
41
|
|
38
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkiterb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- dean@deanpcmad.com
|
30
30
|
executables: []
|
@@ -46,32 +46,25 @@ files:
|
|
46
46
|
- lib/buildkite.rb
|
47
47
|
- lib/buildkite/client.rb
|
48
48
|
- lib/buildkite/collection.rb
|
49
|
+
- lib/buildkite/configuration.rb
|
49
50
|
- lib/buildkite/error.rb
|
51
|
+
- lib/buildkite/models/access_token.rb
|
52
|
+
- lib/buildkite/models/agent.rb
|
53
|
+
- lib/buildkite/models/annotation.rb
|
54
|
+
- lib/buildkite/models/artifact.rb
|
55
|
+
- lib/buildkite/models/artifact_download.rb
|
56
|
+
- lib/buildkite/models/build.rb
|
57
|
+
- lib/buildkite/models/cluster.rb
|
58
|
+
- lib/buildkite/models/cluster_queue.rb
|
59
|
+
- lib/buildkite/models/cluster_token.rb
|
60
|
+
- lib/buildkite/models/emoji.rb
|
61
|
+
- lib/buildkite/models/job.rb
|
62
|
+
- lib/buildkite/models/job_env.rb
|
63
|
+
- lib/buildkite/models/job_log.rb
|
64
|
+
- lib/buildkite/models/organization.rb
|
65
|
+
- lib/buildkite/models/pipeline.rb
|
66
|
+
- lib/buildkite/models/user.rb
|
50
67
|
- lib/buildkite/object.rb
|
51
|
-
- lib/buildkite/objects/access_token.rb
|
52
|
-
- lib/buildkite/objects/agent.rb
|
53
|
-
- lib/buildkite/objects/annotation.rb
|
54
|
-
- lib/buildkite/objects/artifact.rb
|
55
|
-
- lib/buildkite/objects/artifact_download.rb
|
56
|
-
- lib/buildkite/objects/build.rb
|
57
|
-
- lib/buildkite/objects/emoji.rb
|
58
|
-
- lib/buildkite/objects/job.rb
|
59
|
-
- lib/buildkite/objects/job_env.rb
|
60
|
-
- lib/buildkite/objects/job_log.rb
|
61
|
-
- lib/buildkite/objects/organization.rb
|
62
|
-
- lib/buildkite/objects/pipeline.rb
|
63
|
-
- lib/buildkite/objects/user.rb
|
64
|
-
- lib/buildkite/resource.rb
|
65
|
-
- lib/buildkite/resources/access_token.rb
|
66
|
-
- lib/buildkite/resources/agents.rb
|
67
|
-
- lib/buildkite/resources/annotations.rb
|
68
|
-
- lib/buildkite/resources/artifacts.rb
|
69
|
-
- lib/buildkite/resources/builds.rb
|
70
|
-
- lib/buildkite/resources/emojis.rb
|
71
|
-
- lib/buildkite/resources/jobs.rb
|
72
|
-
- lib/buildkite/resources/organizations.rb
|
73
|
-
- lib/buildkite/resources/pipelines.rb
|
74
|
-
- lib/buildkite/resources/user.rb
|
75
68
|
- lib/buildkite/version.rb
|
76
69
|
- lib/buildkiterb.rb
|
77
70
|
homepage: https://deanpcmad.com
|
@@ -80,7 +73,7 @@ licenses:
|
|
80
73
|
metadata:
|
81
74
|
homepage_uri: https://deanpcmad.com
|
82
75
|
source_code_uri: https://github.com/deanpcmad/buildkiterb
|
83
|
-
post_install_message:
|
76
|
+
post_install_message:
|
84
77
|
rdoc_options: []
|
85
78
|
require_paths:
|
86
79
|
- lib
|
@@ -95,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
88
|
- !ruby/object:Gem::Version
|
96
89
|
version: '0'
|
97
90
|
requirements: []
|
98
|
-
rubygems_version: 3.4.
|
99
|
-
signing_key:
|
91
|
+
rubygems_version: 3.4.18
|
92
|
+
signing_key:
|
100
93
|
specification_version: 4
|
101
94
|
summary: A Ruby library for the Buildkite API
|
102
95
|
test_files: []
|
data/lib/buildkite/resource.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
module Buildkite
|
2
|
-
class Resource
|
3
|
-
attr_reader :client
|
4
|
-
|
5
|
-
def initialize(client)
|
6
|
-
@client = client
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def get_request(url, params: {}, headers: {})
|
12
|
-
handle_response client.connection.get(url, params, headers)
|
13
|
-
end
|
14
|
-
|
15
|
-
def post_request(url, body:, headers: {})
|
16
|
-
handle_response client.connection.post(url, body, headers)
|
17
|
-
end
|
18
|
-
|
19
|
-
def patch_request(url, body:, headers: {})
|
20
|
-
handle_response client.connection.patch(url, body, headers)
|
21
|
-
end
|
22
|
-
|
23
|
-
def put_request(url, body:, headers: {})
|
24
|
-
handle_response client.connection.put(url, body, headers)
|
25
|
-
end
|
26
|
-
|
27
|
-
def delete_request(url, params: {}, headers: {})
|
28
|
-
handle_response client.connection.delete(url, params, headers)
|
29
|
-
end
|
30
|
-
|
31
|
-
def handle_response(response)
|
32
|
-
case response.status
|
33
|
-
when 400
|
34
|
-
raise Error, "Error 400: Your request was malformed. '#{response.body["message"]}'"
|
35
|
-
when 401
|
36
|
-
raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["message"]}'"
|
37
|
-
when 403
|
38
|
-
raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["message"]}'"
|
39
|
-
when 404
|
40
|
-
raise Error, "Error 404: No results were found for your request. '#{response.body["message"]}'"
|
41
|
-
when 409
|
42
|
-
raise Error, "Error 409: Your request was a conflict. '#{response.body["message"]}'"
|
43
|
-
when 422
|
44
|
-
raise Error, "Error 422: Unprocessable Entity. '#{response.body["message"]}"
|
45
|
-
when 429
|
46
|
-
raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["message"]}'"
|
47
|
-
when 500
|
48
|
-
raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["message"]}'"
|
49
|
-
when 503
|
50
|
-
raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["message"]}'"
|
51
|
-
when 204
|
52
|
-
# 204 is a response for success
|
53
|
-
return true
|
54
|
-
end
|
55
|
-
|
56
|
-
response
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Buildkite
|
2
|
-
class AgentsResource < Resource
|
3
|
-
|
4
|
-
def list(org:)
|
5
|
-
response = get_request("organizations/#{org}/agents")
|
6
|
-
Collection.from_response(response, type: Agent)
|
7
|
-
end
|
8
|
-
|
9
|
-
def get(org:, id:)
|
10
|
-
Agent.new get_request("organizations/#{org}/agents/#{id}").body
|
11
|
-
end
|
12
|
-
|
13
|
-
def stop(org:, id:, **args)
|
14
|
-
put_request("organizations/#{org}/agents/#{id}/stop", body: args)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Buildkite
|
2
|
-
class AnnotationsResource < Resource
|
3
|
-
|
4
|
-
def list(org:, pipeline:, build:)
|
5
|
-
response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/annotations")
|
6
|
-
Collection.from_response(response, type: Annotation)
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Buildkite
|
2
|
-
class ArtifactsResource < Resource
|
3
|
-
|
4
|
-
def list(org:, pipeline:, build:, job: nil)
|
5
|
-
if job
|
6
|
-
response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts")
|
7
|
-
else
|
8
|
-
response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/artifacts")
|
9
|
-
end
|
10
|
-
|
11
|
-
Collection.from_response(response, type: Artifact)
|
12
|
-
end
|
13
|
-
|
14
|
-
def get(org:, pipeline:, build:, job:, id:)
|
15
|
-
Artifact.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts/#{id}").body
|
16
|
-
end
|
17
|
-
|
18
|
-
def download(org:, pipeline:, build:, job:, id:)
|
19
|
-
ArtifactDownload.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts/#{id}/download").body
|
20
|
-
end
|
21
|
-
|
22
|
-
def delete(org:, pipeline:, build:, job:, id:)
|
23
|
-
delete_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts/#{id}")
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Buildkite
|
2
|
-
class BuildsResource < Resource
|
3
|
-
|
4
|
-
def list(org: nil, pipeline: nil)
|
5
|
-
if org && pipeline
|
6
|
-
response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds")
|
7
|
-
elsif org
|
8
|
-
response = get_request("organizations/#{org}/builds")
|
9
|
-
else
|
10
|
-
response = get_request("builds")
|
11
|
-
end
|
12
|
-
|
13
|
-
if response
|
14
|
-
Collection.from_response(response, type: Build)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def get(org:, pipeline:, number:)
|
19
|
-
Build.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}").body
|
20
|
-
end
|
21
|
-
|
22
|
-
def create(org:, pipeline:, commit:, branch:, **args)
|
23
|
-
data = {commit: commit, branch: branch}
|
24
|
-
Build.new post_request("organizations/#{org}/pipelines/#{pipeline}/builds", body: data.merge(args)).body
|
25
|
-
end
|
26
|
-
|
27
|
-
def cancel(org:, pipeline:, number:)
|
28
|
-
Build.new put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/cancel", body: {}).body
|
29
|
-
end
|
30
|
-
|
31
|
-
def rebuild(org:, pipeline:, number:)
|
32
|
-
Build.new put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/rebuild", body: {}).body
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Buildkite
|
2
|
-
class JobsResource < Resource
|
3
|
-
|
4
|
-
def retry(org:, pipeline:, number:, job:)
|
5
|
-
Job.new put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/retry", body: {}).body
|
6
|
-
end
|
7
|
-
|
8
|
-
def unblock(org:, pipeline:, number:, job:, **args)
|
9
|
-
Job.new put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/unblock", body: args).body
|
10
|
-
end
|
11
|
-
|
12
|
-
def log(org:, pipeline:, number:, job:)
|
13
|
-
JobLog.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/log").body
|
14
|
-
end
|
15
|
-
|
16
|
-
def delete_log(org:, pipeline:, number:, job:)
|
17
|
-
delete_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/log")
|
18
|
-
end
|
19
|
-
|
20
|
-
def env(org:, pipeline:, number:, job:)
|
21
|
-
JobEnv.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/env").body["env"]
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|