buildbox 0.6.beta1 → 0.6.beta2
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 -2
- data/lib/buildbox/agent.rb +1 -8
- data/lib/buildbox/server.rb +1 -0
- data/lib/buildbox/uploader.rb +29 -10
- data/lib/buildbox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d09a24715e1c3a79b74647a1b775b7166cdcf952
|
4
|
+
data.tar.gz: 124c2dad15dbe1e38273803411e2eb73095cee42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 039183e2b691d6f18c4e009ec9468bed4225f3d90d15c200ea72773e86f53646a49c6ab8791ad12dd124f185f7f5b23481e005b1b978a4760b599f9cdf6d43b6
|
7
|
+
data.tar.gz: e87d1f3ce2c272bee640828402baf01e28eca316b4319bed05598f35de6c89cb7d5f926f1e038329782080ab515c42ed741a5983e3cef81cb7672466ac284daa
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
buildbox (0.6.
|
4
|
+
buildbox (0.6.beta2)
|
5
5
|
celluloid (~> 0.14)
|
6
6
|
childprocess (~> 0.3)
|
7
7
|
faraday (~> 0.8)
|
@@ -27,7 +27,6 @@ GEM
|
|
27
27
|
faraday_middleware (0.9.0)
|
28
28
|
faraday (>= 0.7.4, < 0.9)
|
29
29
|
ffi (1.9.3)
|
30
|
-
ffi (1.9.3-x86-mingw32)
|
31
30
|
hashie (2.0.5)
|
32
31
|
lockfile (2.1.0)
|
33
32
|
mime-types (2.0)
|
data/lib/buildbox/agent.rb
CHANGED
@@ -8,7 +8,6 @@ module Buildbox
|
|
8
8
|
def initialize(access_token, api = Buildbox::API.new)
|
9
9
|
@api = api
|
10
10
|
@access_token = access_token
|
11
|
-
@uploader_pool = Uploader.pool(:size => 10) # upload 10 things at a time
|
12
11
|
end
|
13
12
|
|
14
13
|
def process
|
@@ -46,13 +45,7 @@ module Buildbox
|
|
46
45
|
files = Artifact.files_to_upload(build_directory, artifact_path)
|
47
46
|
|
48
47
|
files.each_pair do |relative_path, absolute_path|
|
49
|
-
|
50
|
-
:path => relative_path,
|
51
|
-
:file_size => File.size(absolute_path))
|
52
|
-
|
53
|
-
@uploader_pool.upload(artifact[:uploader], absolute_path) do |state, response|
|
54
|
-
@api.update_artifact(@access_token, @current_build, artifact[:id], :state => state)
|
55
|
-
end
|
48
|
+
Celluloid::Actor[:uploader_pool].async.upload(@api, @access_token, @current_build, relative_path, absolute_path)
|
56
49
|
end
|
57
50
|
rescue => e
|
58
51
|
error "There was an error uploading artifacts for path: #{artifact_path} (#{e.class.name}: #{e.message})"
|
data/lib/buildbox/server.rb
CHANGED
data/lib/buildbox/uploader.rb
CHANGED
@@ -6,15 +6,22 @@ module Buildbox
|
|
6
6
|
include Celluloid
|
7
7
|
include Celluloid::Logger
|
8
8
|
|
9
|
-
def upload(
|
9
|
+
def upload(api, access_token, current_build, relative_path, absolute_path)
|
10
10
|
info "Uploading #{absolute_path}"
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
artifact = api.create_artifact(access_token, current_build,
|
13
|
+
:path => relative_path,
|
14
|
+
:file_size => File.size(absolute_path))
|
14
15
|
|
15
|
-
|
16
|
+
|
17
|
+
upload_action = artifact[:uploader][:action]
|
18
|
+
form_data = artifact[:uploader][:data].to_hash.dup
|
19
|
+
|
20
|
+
connection = Faraday.new(:url => upload_action[:url]) do |faraday|
|
16
21
|
faraday.request :multipart
|
17
22
|
|
23
|
+
faraday.response :raise_error
|
24
|
+
|
18
25
|
faraday.options[:timeout] = 60
|
19
26
|
faraday.options[:open_timeout] = 60
|
20
27
|
|
@@ -22,18 +29,30 @@ module Buildbox
|
|
22
29
|
end
|
23
30
|
|
24
31
|
mime_type = MIME::Types.type_for(absolute_path)[0].to_s
|
25
|
-
file_input_key = action[:file_input]
|
26
32
|
|
27
|
-
|
33
|
+
file_input_key = upload_action[:file_input]
|
28
34
|
form_data[file_input_key] = Faraday::UploadIO.new(absolute_path, mime_type)
|
29
35
|
|
30
|
-
|
36
|
+
api.update_artifact(access_token, current_build, artifact[:id], :state => 'uploading')
|
31
37
|
|
32
|
-
|
38
|
+
upload_exception = nil
|
39
|
+
response = nil
|
33
40
|
|
34
|
-
|
41
|
+
begin
|
42
|
+
response = connection.post(upload_action[:path], form_data)
|
43
|
+
rescue => e
|
44
|
+
upload_exception = e
|
45
|
+
end
|
46
|
+
|
47
|
+
if upload_exception
|
48
|
+
error "Error uploading #{File.basename(absolute_path)} with a status of (#{upload_exception.class.name}: #{upload_exception.message})"
|
49
|
+
finished_state = 'error'
|
50
|
+
else
|
51
|
+
info "Finished uploading #{File.basename(absolute_path)} with a status of #{response.status}"
|
52
|
+
finished_state = 'finished'
|
53
|
+
end
|
35
54
|
|
36
|
-
|
55
|
+
api.update_artifact(access_token, current_build, artifact[:id], :state => finished_state)
|
37
56
|
end
|
38
57
|
end
|
39
58
|
end
|
data/lib/buildbox/version.rb
CHANGED