vx-builder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d33b75d7dad8e9a9fd0e959b939b7d72c41fc92
|
4
|
+
data.tar.gz: 5666100d3833bc64c8991ac1eb17455d82a9511e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a7054d5bcb3d3898565c25c217afc445b5b02a4afb9886f2542507373e61e885a6b5ce23f6c2f5044afc91ba487fe94178c44979011f56a9415a2b301d9c02d
|
7
|
+
data.tar.gz: 43e5caa852f72420cd4dc8fb2a5322c48d9cdbbbd1ff7c0d5cecbb983d6d5fc71fd6b34523ef0671a48055f84392166caf0074336c7f7471f9f45339a4c62183
|
@@ -9,26 +9,56 @@ module Vx
|
|
9
9
|
normalize_attributes(new_env)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def attributes
|
13
13
|
@attributes
|
14
14
|
end
|
15
15
|
|
16
|
+
def files
|
17
|
+
@files
|
18
|
+
end
|
19
|
+
|
20
|
+
def prefix
|
21
|
+
@options[:prefix]
|
22
|
+
end
|
23
|
+
|
16
24
|
private
|
17
25
|
|
18
26
|
def normalize_attributes(new_env)
|
19
|
-
|
20
|
-
@attributes =
|
27
|
+
attrs =
|
21
28
|
case new_env
|
22
29
|
when Array
|
23
|
-
new_env
|
30
|
+
new_env
|
31
|
+
else
|
32
|
+
Array(new_env)
|
33
|
+
end
|
34
|
+
|
35
|
+
extract_options_and_normalize_items(attrs)
|
36
|
+
end
|
37
|
+
|
38
|
+
def extract_options_and_normalize_items(new_env)
|
39
|
+
opts = {}
|
40
|
+
@attributes = []
|
41
|
+
@files = []
|
42
|
+
env = new_env.inject([]) do |a, e|
|
43
|
+
if e.is_a?(Hash)
|
44
|
+
opts = e
|
45
|
+
@attributes.push e
|
24
46
|
else
|
25
|
-
|
47
|
+
a.push e.to_s.gsub(/^\.*(\/)/, '')
|
48
|
+
@attributes.push a.last
|
49
|
+
@files.push a.last
|
26
50
|
end
|
51
|
+
a
|
52
|
+
end
|
27
53
|
|
28
|
-
|
29
|
-
|
54
|
+
if opts && opts["prefix"]
|
55
|
+
@options = { prefix: opts["prefix"] }
|
56
|
+
else
|
57
|
+
@options = {}
|
30
58
|
end
|
31
59
|
|
60
|
+
[opts, env]
|
61
|
+
|
32
62
|
end
|
33
63
|
|
34
64
|
end
|
@@ -13,13 +13,15 @@ module Vx
|
|
13
13
|
|
14
14
|
if enabled?(env)
|
15
15
|
env.after_script << "echo"
|
16
|
-
env.source.artifacts.
|
16
|
+
env.source.artifacts.files.map{|a| compile(a) }.each do |artifact|
|
17
17
|
find = FIND % artifact
|
18
|
-
|
18
|
+
url = env.task.artifacts_url_prefix
|
19
|
+
prefix = env.source.artifacts.prefix
|
20
|
+
name = prefix ? "#{prefix}$i" : "$i"
|
19
21
|
cmd = %{
|
20
22
|
for i in $(#{find}) ; do
|
21
|
-
echo "upload artifact
|
22
|
-
curl -s -S -X PUT -T $i #{
|
23
|
+
echo "upload artifact #{name}"
|
24
|
+
curl -s -S -X PUT -T $i #{url}/#{name} > /dev/null
|
23
25
|
done
|
24
26
|
}
|
25
27
|
env.after_script << cmd
|
@@ -42,7 +44,7 @@ module Vx
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def enabled?(env)
|
45
|
-
!env.source.artifacts.
|
47
|
+
!env.source.artifacts.files.empty? &&
|
46
48
|
env.task.artifacts_url_prefix
|
47
49
|
end
|
48
50
|
|
data/lib/vx/builder/version.rb
CHANGED
data/spec/fixtures/travis.yml
CHANGED
@@ -43,7 +43,7 @@ describe Vx::Builder::BuildConfiguration do
|
|
43
43
|
"scala" => ['2.10.3'],
|
44
44
|
"script" => ["RAILS_ENV=test ls -1 && echo DONE!"],
|
45
45
|
"services" => ['rabbitmq'],
|
46
|
-
"artifacts" => ["app/foo.txt", "app/*.txt", "app/"]
|
46
|
+
"artifacts" => ["app/foo.txt", "app/*.txt", "app/", {"prefix"=>"$CI_JOB_ID/"}]
|
47
47
|
}
|
48
48
|
) }
|
49
49
|
end
|
@@ -100,8 +100,13 @@ describe Vx::Builder::BuildConfiguration do
|
|
100
100
|
context "artifacts" do
|
101
101
|
subject { config.artifacts }
|
102
102
|
|
103
|
+
its(:prefix) { should eq "$CI_JOB_ID/" }
|
104
|
+
its(:files) { should eq ["app/foo.txt", "app/*.txt", "app/"] }
|
105
|
+
|
103
106
|
context "when is empty" do
|
104
107
|
let(:content) { {} }
|
108
|
+
its(:files) { should eq [] }
|
109
|
+
its(:prefix) { should be_nil }
|
105
110
|
its(:attributes) { should eq [] }
|
106
111
|
end
|
107
112
|
end
|