socotra-build 0.3.11 → 0.3.12
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/lib/socotra-build.rb +26 -27
- 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: 4e0e0d7f0f50fbe044494d7ff23d4394927a75cb
|
|
4
|
+
data.tar.gz: 8d020afbdcdf2c8044aedb7087814d78d0a8d56a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11f33eda69902159c0d16762692cf24600773c35dfcd2578d4bdd4d1618a1a4dec818b3ab2aa21b18c909265891503e03a867a6a15ed47716e82c6b77f9e903d
|
|
7
|
+
data.tar.gz: e7fda3856040216d84623b2e9de5045743b852a2654f94fbc551b31c631b409450948474bc811f6183eaa9fbe0c3658ec0804a60561dc0bf252a7683333556ca
|
data/lib/socotra-build.rb
CHANGED
|
@@ -2,22 +2,22 @@ require 'open3'
|
|
|
2
2
|
require 'set'
|
|
3
3
|
|
|
4
4
|
def self.safe_retry(cmd, description, error_message="command failed", raise_on_fail=true, log_level="ERROR", log=true, tries=3)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
begin
|
|
6
|
+
status, output = system_safe(cmd, description, error_message, raise_on_fail=raise_on_fail, log_level=log_level, log=log)
|
|
7
|
+
rescue
|
|
8
|
+
if (tries -= 1) > 0
|
|
9
|
+
puts "\n#{cmd} failed, retry attempt #{tries}\n"
|
|
10
|
+
sleep 5
|
|
11
|
+
retry unless (tries).zero?
|
|
12
|
+
else
|
|
13
|
+
puts "ERROR: see logs/#{description}_out.log and #{description}_err.log for details"
|
|
14
|
+
if raise_on_fail
|
|
15
|
+
raise "ERROR: #{error_message}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
return status
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def self.system_safe(cmd, cmd_description, error_message, raise_on_fail=true, log_level="ERROR", log=true, print_command=true)
|
|
@@ -45,25 +45,24 @@ def self.system_safe(cmd, cmd_description, error_message, raise_on_fail=true, lo
|
|
|
45
45
|
cmd = cmd.gsub(/\s+/m, ' ').strip.split(" ")
|
|
46
46
|
replace = cmd.grep(Regexp.union(secret_fields))
|
|
47
47
|
unless replace.empty?
|
|
48
|
-
puts replace
|
|
49
48
|
replace = Set.new replace
|
|
50
49
|
cmd.collect! {|e| (replace.include? e) ? '<secret>': e}
|
|
51
50
|
end
|
|
52
51
|
cmd = cmd.join(' ')
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
if print_command
|
|
54
|
+
puts "Executing command: #{cmd}\n"
|
|
55
|
+
else
|
|
56
|
+
puts "Not logging command"
|
|
57
|
+
end
|
|
59
58
|
|
|
60
59
|
if log
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
File.open("logs/#{cmd_description}_out.log" , 'w') { |file| file.write(stdout) }
|
|
61
|
+
File.open("logs/#{cmd_description}_err.log" , 'w') { |file| file.write(stderr) }
|
|
62
|
+
puts "\tLogs available here: #{cmd_description}_err.log and #{cmd_description}_out.log\n\n"
|
|
63
|
+
else
|
|
64
|
+
puts "Not logging due to secrets in output"
|
|
65
|
+
end
|
|
67
66
|
|
|
68
67
|
puts "\t#{cmd_description} took #{elapsed} seconds"
|
|
69
68
|
|