buildbox 0.3.9.1 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -6
- data/lib/buildbox/agent.rb +4 -4
- data/lib/buildbox/api.rb +7 -13
- data/lib/buildbox/cli.rb +3 -31
- data/lib/buildbox/configuration.rb +1 -8
- data/lib/buildbox/monitor.rb +8 -7
- data/lib/buildbox/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27d1513d8d309bceab4f388476844564a5163ff7
|
4
|
+
data.tar.gz: 40dca9e43b72d5faff3e1bd0fa0b50da2fea8de7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d737db962c9335eb724e0538813282e5a2f197431fc49bb17f05b7e20d5a5908f227db59a8af6976a7f7eb4fab813dffef28fd8924b6cf76835f9234bf40b69d
|
7
|
+
data.tar.gz: 3ba1a9106292b8e7c42518a4b46488079d6ca28d76cc88abbfabace11cc28391ffaf552320af0de72cf2e6a1fb8c2c4e4f835b7532df33f249e85f9e439e200b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,14 +5,10 @@
|
|
5
5
|
Install the gem
|
6
6
|
|
7
7
|
$ gem install buildbox
|
8
|
-
|
9
|
-
Authenticate
|
10
8
|
|
11
|
-
|
9
|
+
Add your agent access token
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
$ buildbox agent:setup [token]
|
11
|
+
$ buildbox agent:setup [agent_access_token]
|
16
12
|
|
17
13
|
Then you can start monitoring for builds like so:
|
18
14
|
|
data/lib/buildbox/agent.rb
CHANGED
@@ -19,9 +19,9 @@ module Buildbox
|
|
19
19
|
|
20
20
|
while build = @queue.pop do
|
21
21
|
# Let the agent know that we're about to start running this build
|
22
|
-
@api.update_build(build, :agent_accepted => @access_token)
|
22
|
+
@api.update_build(@access_token, build, :agent_accepted => @access_token)
|
23
23
|
|
24
|
-
Monitor.new(build, @api).async.monitor
|
24
|
+
Monitor.new(build, @access_token, @api).async.monitor
|
25
25
|
Runner.new(build).start
|
26
26
|
end
|
27
27
|
|
@@ -32,8 +32,8 @@ module Buildbox
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def scheduled_builds
|
35
|
-
|
36
|
-
@api.scheduled_builds
|
35
|
+
@api.agent(@access_token, :hostname => hostname, :version => Buildbox::VERSION)
|
36
|
+
@api.scheduled_builds(@access_token)
|
37
37
|
rescue Buildbox::API::AgentNotFoundError
|
38
38
|
warn "Agent `#{@access_token}` does not exist"
|
39
39
|
[] # return empty array to avoid breakage
|
data/lib/buildbox/api.rb
CHANGED
@@ -12,6 +12,7 @@ module Buildbox
|
|
12
12
|
def initialize(logger)
|
13
13
|
@logger = logger
|
14
14
|
end
|
15
|
+
|
15
16
|
def info(*args)
|
16
17
|
@logger.debug(*args)
|
17
18
|
end
|
@@ -29,35 +30,28 @@ module Buildbox
|
|
29
30
|
@logger = logger
|
30
31
|
end
|
31
32
|
|
32
|
-
def authenticate(api_key)
|
33
|
-
@api_key = api_key
|
34
|
-
|
35
|
-
get("user")
|
36
|
-
end
|
37
|
-
|
38
33
|
def agent(access_token, options)
|
39
|
-
put(
|
34
|
+
put(access_token, options)
|
40
35
|
rescue Faraday::Error::ClientError => e
|
41
|
-
if e.response[:status] == 404
|
36
|
+
if e.response && e.response[:status] == 404
|
42
37
|
raise AgentNotFoundError.new(e, e.response)
|
43
38
|
else
|
44
39
|
raise ServerError.new(e, e.response)
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
48
|
-
def scheduled_builds(
|
49
|
-
get(
|
43
|
+
def scheduled_builds(access_token)
|
44
|
+
get("#{access_token}/builds/scheduled").map { |build| Buildbox::Build.new(build) }
|
50
45
|
end
|
51
46
|
|
52
|
-
def update_build(build, options)
|
53
|
-
put(build.
|
47
|
+
def update_build(access_token, build, options)
|
48
|
+
put("#{access_token}/builds/#{build.id}", options)
|
54
49
|
end
|
55
50
|
|
56
51
|
private
|
57
52
|
|
58
53
|
def connection
|
59
54
|
@connection ||= Faraday.new(:url => @config.api_endpoint) do |faraday|
|
60
|
-
faraday.basic_auth @api_key || @config.api_key, ''
|
61
55
|
faraday.request :retry
|
62
56
|
faraday.request :json
|
63
57
|
|
data/lib/buildbox/cli.rb
CHANGED
@@ -9,11 +9,11 @@ module Buildbox
|
|
9
9
|
@commands = {}
|
10
10
|
@options = {}
|
11
11
|
|
12
|
-
@commands['
|
13
|
-
opts.banner = "Usage: buildbox
|
12
|
+
@commands['agent:setup'] = OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: buildbox agent:setup [token]"
|
14
14
|
|
15
15
|
opts.on("--help", "You're looking at it.") do
|
16
|
-
puts @commands['
|
16
|
+
puts @commands['agent:setup']
|
17
17
|
exit
|
18
18
|
end
|
19
19
|
end
|
@@ -27,15 +27,6 @@ module Buildbox
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
@commands['agent:setup'] = OptionParser.new do |opts|
|
31
|
-
opts.banner = "Usage: buildbox agent:setup [token]"
|
32
|
-
|
33
|
-
opts.on("--help", "You're looking at it.") do
|
34
|
-
puts @commands['agent:setup']
|
35
|
-
exit
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
30
|
@commands['version'] = OptionParser.new do |opts|
|
40
31
|
opts.banner = "Usage: buildbox version"
|
41
32
|
end
|
@@ -74,24 +65,6 @@ module Buildbox
|
|
74
65
|
puts "Successfully added agent access token"
|
75
66
|
puts "You can now start the agent with: buildbox agent:start."
|
76
67
|
puts "If the agent is already running, you'll have to restart it for the new changes to take effect"
|
77
|
-
elsif command == "auth:login"
|
78
|
-
if @argv.length == 0
|
79
|
-
puts "No api key provided"
|
80
|
-
exit 1
|
81
|
-
end
|
82
|
-
|
83
|
-
api_key = @argv.first
|
84
|
-
|
85
|
-
begin
|
86
|
-
Buildbox::API.new.authenticate(api_key)
|
87
|
-
Buildbox.config.update(:api_key => api_key)
|
88
|
-
|
89
|
-
puts "Successfully added your api_key"
|
90
|
-
puts "You can now add agents with: buildbox agent:setup [agent_token]"
|
91
|
-
rescue
|
92
|
-
puts "Could not authenticate your api_key"
|
93
|
-
exit 1
|
94
|
-
end
|
95
68
|
end
|
96
69
|
else
|
97
70
|
puts global.help
|
@@ -112,7 +85,6 @@ module Buildbox
|
|
112
85
|
def help
|
113
86
|
<<HELP
|
114
87
|
|
115
|
-
auth:login [api_key] # login to buildbox
|
116
88
|
agent:setup [access_token] # set the access token for the agent
|
117
89
|
agent:start # start the buildbox agent
|
118
90
|
version # display version
|
@@ -18,14 +18,7 @@ module Buildbox
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def api_endpoint
|
21
|
-
ENV['BUILDBOX_API_ENDPOINT'] || self[:api_endpoint] || "https://
|
22
|
-
end
|
23
|
-
|
24
|
-
def check
|
25
|
-
unless api_key
|
26
|
-
puts "No api_key set. You can set it with\nbuildbox auth:login [api_key]"
|
27
|
-
exit 1
|
28
|
-
end
|
21
|
+
ENV['BUILDBOX_API_ENDPOINT'] || self[:api_endpoint] || "https://agent.buildbox.io/v1"
|
29
22
|
end
|
30
23
|
|
31
24
|
def update(attributes)
|
data/lib/buildbox/monitor.rb
CHANGED
@@ -4,9 +4,10 @@ module Buildbox
|
|
4
4
|
class Monitor
|
5
5
|
include Celluloid
|
6
6
|
|
7
|
-
def initialize(build, api)
|
8
|
-
@build
|
9
|
-
@
|
7
|
+
def initialize(build, access_token, api)
|
8
|
+
@build = build
|
9
|
+
@access_token = access_token
|
10
|
+
@api = api
|
10
11
|
end
|
11
12
|
|
12
13
|
def monitor
|
@@ -17,10 +18,10 @@ module Buildbox
|
|
17
18
|
# same finished_at timestamp throughout the entire method.
|
18
19
|
finished_at = @build.finished_at
|
19
20
|
|
20
|
-
updated_build = @api.update_build(@build, :started_at => @build.started_at,
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
updated_build = @api.update_build(@access_token, @build, :started_at => @build.started_at,
|
22
|
+
:finished_at => finished_at,
|
23
|
+
:output => @build.output,
|
24
|
+
:exit_status => @build.exit_status)
|
24
25
|
|
25
26
|
if updated_build.state == 'canceled' && !@build.cancelling?
|
26
27
|
Buildbox::Canceler.new(@build).async.cancel
|
data/lib/buildbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Pitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
227
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.
|
228
|
+
rubygems_version: 2.0.3
|
229
229
|
signing_key:
|
230
230
|
specification_version: 4
|
231
231
|
summary: Ruby agent for buildbox
|