depengine 3.0.20 → 3.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +52 -0
- data/Gemfile.lock +16 -1
- data/Rakefile +9 -9
- data/bin/cdb_crypt +2 -2
- data/bin/de +1 -1
- data/bin/depengine +2 -2
- data/bin/spec_setup +2 -2
- data/depengine.gemspec +22 -21
- data/lib/depengine/asserter/url.rb +8 -9
- data/lib/depengine/cli.rb +12 -14
- data/lib/depengine/dsl/cdb.rb +16 -17
- data/lib/depengine/dsl/deployment.rb +42 -50
- data/lib/depengine/dsl/dweb.rb +10 -11
- data/lib/depengine/dsl/executor.rb +5 -5
- data/lib/depengine/dsl/fileops.rb +3 -4
- data/lib/depengine/dsl/helper.rb +26 -28
- data/lib/depengine/dsl/iis.rb +21 -24
- data/lib/depengine/dsl/patch.rb +22 -46
- data/lib/depengine/dsl/publisher.rb +14 -14
- data/lib/depengine/dsl/remote.rb +11 -13
- data/lib/depengine/dsl/repository.rb +19 -21
- data/lib/depengine/dsl/template.rb +19 -19
- data/lib/depengine/dsl/zip.rb +24 -24
- data/lib/depengine/helper/cli_helper.rb +9 -11
- data/lib/depengine/helper/hudson.rb +15 -19
- data/lib/depengine/helper/mail.rb +19 -25
- data/lib/depengine/helper/properties.rb +33 -52
- data/lib/depengine/helper/smb.rb +19 -25
- data/lib/depengine/helper/validations.rb +7 -7
- data/lib/depengine/helper/yaml.rb +7 -9
- data/lib/depengine/log/log.rb +3 -6
- data/lib/depengine/processor/erb_template.rb +42 -47
- data/lib/depengine/processor/fileops.rb +39 -48
- data/lib/depengine/processor/local_execute.rb +6 -4
- data/lib/depengine/processor/properties.rb +34 -56
- data/lib/depengine/processor/sed.rb +8 -12
- data/lib/depengine/processor/tags.rb +9 -10
- data/lib/depengine/processor/template.rb +27 -32
- data/lib/depengine/processor/zip.rb +16 -20
- data/lib/depengine/provider/cdb.rb +64 -71
- data/lib/depengine/provider/cdb_filesystem.rb +18 -26
- data/lib/depengine/provider/git.rb +37 -42
- data/lib/depengine/provider/repository.rb +161 -176
- data/lib/depengine/publisher/dweb.rb +74 -90
- data/lib/depengine/publisher/iis.rb +23 -30
- data/lib/depengine/publisher/rsync.rb +14 -17
- data/lib/depengine/publisher/samba.rb +12 -14
- data/lib/depengine/publisher/sftp.rb +51 -61
- data/lib/depengine/publisher/ssh.rb +19 -22
- data/lib/depengine/publisher/tomcat.rb +19 -21
- data/lib/depengine/reporter/cdb.rb +2 -3
- data/lib/depengine/version.rb +1 -1
- data/lib/depengine.rb +1 -2
- data/spec/cdb_spec.rb +8 -10
- data/spec/demo_recipe/recipes/demo.rb +10 -10
- data/spec/deployhelper_spec.rb +20 -21
- data/spec/fileops_spec.rb +11 -12
- data/spec/git_spec.rb +8 -4
- data/spec/helper_spec.rb +75 -75
- data/spec/junit.rb +47 -49
- data/spec/local_execute.rb +7 -7
- data/spec/log_spec.rb +17 -18
- data/spec/properties_spec.rb +13 -15
- data/spec/recipe_spec.rb +15 -16
- data/spec/repository_spec.rb +20 -20
- data/spec/ssh_spec.rb +18 -19
- data/spec/template_spec.rb +30 -30
- data/spec/zip_spec.rb +7 -7
- metadata +18 -2
@@ -20,48 +20,44 @@ module Publisher
|
|
20
20
|
# debug with:
|
21
21
|
# ssh -i apps/deploy_engine/etc/ssh/id_rsa.deployadmin dwebuser@dei[iup]2s.dweb.intranet.db.com
|
22
22
|
# > 'enter command'
|
23
|
-
def send_command(command, options={})
|
24
|
-
Helper.validates_presence_of staging_host,
|
25
|
-
Helper.validates_presence_of ssh_key_file,
|
26
|
-
Helper.validates_presence_of siteid,
|
23
|
+
def send_command(command, options = {})
|
24
|
+
Helper.validates_presence_of staging_host, 'Staging Host not set'
|
25
|
+
Helper.validates_presence_of ssh_key_file, 'SSH keyfile not set'
|
26
|
+
Helper.validates_presence_of siteid, 'Siteid not set'
|
27
27
|
|
28
28
|
result = ''
|
29
29
|
joined_filename = File.join(File.dirname($exec_file_path), ssh_key_file)
|
30
30
|
ssh_key_file = joined_filename
|
31
31
|
|
32
32
|
# overwrite siteid for multi target deployments
|
33
|
-
|
34
|
-
self.siteid = options[:siteid]
|
35
|
-
end
|
33
|
+
self.siteid = options[:siteid] if options[:siteid]
|
36
34
|
|
37
35
|
# check ssh keyfile
|
38
|
-
|
36
|
+
unless File.file? ssh_key_file
|
39
37
|
$log.writer.error "Can not find SSH keyfile #{ssh_key_file}"
|
40
|
-
|
38
|
+
fail "Can not find SSH keyfile #{ssh_key_file}"
|
41
39
|
end
|
42
40
|
|
43
41
|
### Probleme auf UAT und PROD
|
44
|
-
if command.include?
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
:
|
50
|
-
:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
if not success
|
56
|
-
$log.writer.error "Can not execute dwebuser command"
|
42
|
+
return result if command.include? 'list'
|
43
|
+
|
44
|
+
Net::SSH.start(staging_host, 'dwebuser', \
|
45
|
+
auth_methods: ['publickey'], \
|
46
|
+
forward_agent: false, \
|
47
|
+
keys: ssh_key_file, \
|
48
|
+
timeout: 90) do |session|
|
49
|
+
session.open_channel do |channel|
|
50
|
+
channel.exec "/scripts/dwebuser #{siteid}" do |ch, success|
|
51
|
+
unless success
|
52
|
+
$log.writer.error 'Can not execute dwebuser command'
|
57
53
|
exit 1
|
58
54
|
end
|
59
55
|
|
60
|
-
ch.on_data do |
|
61
|
-
|
56
|
+
ch.on_data do |_ch, data|
|
57
|
+
unless data.empty?
|
62
58
|
result << data
|
63
59
|
|
64
|
-
if command.include?
|
60
|
+
if command.include? 'list'
|
65
61
|
result_a = result.split("\n")
|
66
62
|
test = result_a.last
|
67
63
|
if not test.nil? and test.length > 0
|
@@ -73,7 +69,7 @@ module Publisher
|
|
73
69
|
end
|
74
70
|
|
75
71
|
# something on stderr?
|
76
|
-
ch.on_extended_data do |
|
72
|
+
ch.on_extended_data do |_ch, _type, data|
|
77
73
|
# dirty filter for non critical return messages
|
78
74
|
if data =~ /^ERROR.*/
|
79
75
|
$log.writer.error \
|
@@ -85,82 +81,79 @@ module Publisher
|
|
85
81
|
end
|
86
82
|
end
|
87
83
|
|
88
|
-
ch.on_close do |
|
89
|
-
result <<
|
84
|
+
ch.on_close do |_ch|
|
85
|
+
result << 'all done, closing ssh channel!'
|
90
86
|
end
|
91
87
|
|
92
88
|
ch.send_data command + "\n"
|
93
89
|
end
|
94
|
-
|
90
|
+
channel.wait
|
95
91
|
end
|
96
92
|
end
|
97
93
|
$log.writer.debug result
|
98
94
|
|
99
|
-
|
95
|
+
result
|
100
96
|
end
|
101
97
|
|
102
|
-
def upload(source, target, options={})
|
103
|
-
Helper.validates_presence_of staging_host,
|
104
|
-
Helper.validates_presence_of ssh_key_file,
|
98
|
+
def upload(source, target, options = {})
|
99
|
+
Helper.validates_presence_of staging_host, 'Staging Host not set'
|
100
|
+
Helper.validates_presence_of ssh_key_file, 'SSH keyfile not set'
|
105
101
|
|
106
|
-
result = ''
|
107
102
|
joined_filename = File.join(File.dirname($exec_file_path), ssh_key_file)
|
108
103
|
ssh_key_file = joined_filename
|
109
104
|
|
110
105
|
# overwrite siteid for multi target deployments
|
111
|
-
|
112
|
-
|
113
|
-
end
|
114
|
-
Helper.validates_presence_of siteid, "Siteid not set"
|
106
|
+
self.siteid = options[:siteid] if options[:siteid]
|
107
|
+
Helper.validates_presence_of siteid, 'Siteid not set'
|
115
108
|
|
116
109
|
# check ssh keyfile
|
117
|
-
|
110
|
+
unless File.file? ssh_key_file
|
118
111
|
$log.writer.error "Can not find SSH keyfile #{ssh_key_file}"
|
119
|
-
|
112
|
+
fail "Can not find SSH keyfile #{ssh_key_file}"
|
120
113
|
end
|
121
114
|
|
122
115
|
# first connection to delete files
|
123
116
|
begin
|
124
|
-
|
117
|
+
unless options[:cleanup] == false
|
125
118
|
Net::SFTP.start(staging_host, siteid + 'f', \
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
119
|
+
auth_methods: ['publickey'], \
|
120
|
+
forward_agent: false, \
|
121
|
+
keys: ssh_key_file, \
|
122
|
+
timeout: 90) do |session|
|
130
123
|
|
131
124
|
# delete all files in target, but not the target-dir itself
|
132
125
|
$log.writer.debug "Cleaning remote directory #{target}"
|
133
126
|
session.rm_r!(target)
|
134
|
-
|
127
|
+
|
135
128
|
end
|
136
129
|
end
|
137
130
|
# second connection to upload files
|
138
|
-
processing_file =
|
131
|
+
processing_file = ''
|
139
132
|
Net::SCP.start(staging_host, siteid + 'f', \
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
133
|
+
auth_methods: ['publickey'], \
|
134
|
+
forward_agent: false, \
|
135
|
+
keys: ssh_key_file, \
|
136
|
+
timeout: 90) do |session|
|
144
137
|
Dir.glob(File.join(source, '/*'), File::FNM_DOTMATCH) do |entry|
|
145
|
-
|
138
|
+
unless entry =~ /\.$/
|
146
139
|
processing_file = entry
|
147
140
|
if not options[:excludes].nil?
|
148
|
-
if options[:excludes].any? {|term| entry.include? term }
|
141
|
+
if options[:excludes].any? { |term| entry.include? term }
|
149
142
|
$log.writer.debug "Exclude #{entry} from upload"
|
150
143
|
else
|
151
144
|
$log.writer.debug "Upload #{entry}"
|
152
145
|
session.upload!(entry, File.join(target, '/'), \
|
153
|
-
:
|
146
|
+
recursive: true)
|
154
147
|
end
|
155
148
|
else
|
156
149
|
$log.writer.debug "Upload #{entry}"
|
157
150
|
session.upload!(entry, File.join(target, '/'), \
|
158
|
-
:
|
151
|
+
recursive: true)
|
159
152
|
end
|
160
153
|
end
|
161
154
|
end
|
162
155
|
end
|
163
|
-
rescue
|
156
|
+
rescue => e
|
164
157
|
$log.writer.error "Can not upload file #{processing_file} to #{target}"
|
165
158
|
$log.writer.error e.message
|
166
159
|
$log.writer.error e.backtrace.join("\n")
|
@@ -168,60 +161,54 @@ module Publisher
|
|
168
161
|
end
|
169
162
|
end
|
170
163
|
|
171
|
-
def remote_symlink(source, symlink, options={})
|
172
|
-
Helper.validates_presence_of staging_host,
|
173
|
-
Helper.validates_presence_of ssh_key_file,
|
164
|
+
def remote_symlink(source, symlink, options = {})
|
165
|
+
Helper.validates_presence_of staging_host, 'Staging Host not set'
|
166
|
+
Helper.validates_presence_of ssh_key_file, 'SSH keyfile not set'
|
174
167
|
|
175
|
-
result = ''
|
176
168
|
joined_filename = File.join(File.dirname($exec_file_path), ssh_key_file)
|
177
169
|
ssh_key_file = joined_filename
|
178
170
|
|
179
171
|
# overwrite siteid for multi target deployments
|
180
|
-
|
181
|
-
|
182
|
-
end
|
183
|
-
Helper.validates_presence_of siteid, "Siteid not set"
|
172
|
+
self.siteid = options[:siteid] if options[:siteid]
|
173
|
+
Helper.validates_presence_of siteid, 'Siteid not set'
|
184
174
|
|
185
175
|
# check ssh keyfile
|
186
|
-
|
176
|
+
unless File.file? ssh_key_file
|
187
177
|
$log.writer.error "Can not find SSH keyfile #{ssh_key_file}"
|
188
178
|
exit 1
|
189
179
|
end
|
190
180
|
|
191
181
|
begin
|
192
182
|
Net::SFTP.start(staging_host, siteid + 'f', \
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
session.symlink!(source, symlink)
|
183
|
+
auth_methods: ['publickey'], \
|
184
|
+
forward_agent: false, \
|
185
|
+
keys: ssh_key_file, \
|
186
|
+
timeout: 90) do |session|
|
187
|
+
begin
|
188
|
+
if session.lstat!(symlink).type == Net::SFTP::Protocol::V01::Attributes::T_SYMLINK
|
189
|
+
$log.writer.debug "Delete already existing link #{symlink}"
|
190
|
+
session.remove!(symlink)
|
191
|
+
end
|
192
|
+
rescue
|
193
|
+
$log.writer.warn 'Maybe the link does not exist yet, or the remove faild. Anyway, we try to create it.'
|
194
|
+
end
|
195
|
+
session.symlink!(source, symlink)
|
207
196
|
end
|
208
|
-
rescue
|
209
|
-
$log.writer.error "Can not create remote symlink #{symlink} to #{source}
|
210
|
-
"
|
197
|
+
rescue => e
|
198
|
+
$log.writer.error "Can not create remote symlink #{symlink} to #{source}"
|
211
199
|
$log.writer.error e.message
|
212
200
|
$log.writer.error e.backtrace.join("\n")
|
213
201
|
exit 1
|
214
202
|
end
|
215
203
|
true
|
216
204
|
end
|
217
|
-
|
218
205
|
end
|
219
206
|
end
|
220
207
|
|
221
|
-
class Net::SFTP::Session
|
222
|
-
def rm_r!(path, options={})
|
208
|
+
class Net::SFTP::Session # rubocop:disable Style/ClassAndModuleChildren
|
209
|
+
def rm_r!(path, options = {})
|
223
210
|
@rm_depth = 0 if @rm_depth.nil?
|
224
|
-
|
211
|
+
dir.entries(path).each do |entry|
|
225
212
|
|
226
213
|
next if entry.name == '.' or entry.name == '..'
|
227
214
|
|
@@ -237,9 +224,6 @@ class Net::SFTP::Session
|
|
237
224
|
end
|
238
225
|
end
|
239
226
|
|
240
|
-
if @rm_depth != 0 or options[:delete_root]
|
241
|
-
self.rmdir!(path)
|
242
|
-
end
|
227
|
+
self.rmdir!(path) if @rm_depth != 0 or options[:delete_root]
|
243
228
|
end
|
244
229
|
end
|
245
|
-
|
@@ -3,8 +3,8 @@ module Publisher
|
|
3
3
|
attr_accessor :url, :protocol, :http_read_timeout
|
4
4
|
|
5
5
|
def build(tag, env, version, value, application_name)
|
6
|
-
Helper.validates_presence_of @url,
|
7
|
-
Helper.validates_presence_of @protocol,
|
6
|
+
Helper.validates_presence_of @url, 'IIS URL not set'
|
7
|
+
Helper.validates_presence_of @protocol, 'Protocol not set'
|
8
8
|
iis_error = false
|
9
9
|
|
10
10
|
begin
|
@@ -16,30 +16,27 @@ module Publisher
|
|
16
16
|
request.content_type = 'application/x-www-form-urlencoded;charset=utf-8'
|
17
17
|
http.request request do |response|
|
18
18
|
response.read_body do |chunk|
|
19
|
-
if chunk.include?(
|
20
|
-
$log.writer.error
|
19
|
+
if chunk.include?('### Error while executing')
|
20
|
+
$log.writer.error 'Error executing build on IIS'
|
21
21
|
iis_error = true
|
22
22
|
end
|
23
23
|
$log.writer.info "#{chunk}"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
-
rescue
|
28
|
-
$log.writer.error
|
29
|
-
$log.writer.error "Request was: #{uri
|
27
|
+
rescue => e
|
28
|
+
$log.writer.error 'Error: while connecting to IIS Server'
|
29
|
+
$log.writer.error "Request was: #{uri}"
|
30
30
|
$log.writer.error e.message
|
31
31
|
exit 1
|
32
32
|
end
|
33
33
|
|
34
|
-
if iis_error
|
35
|
-
exit 1
|
36
|
-
end
|
37
|
-
|
34
|
+
fail if iis_error
|
38
35
|
end
|
39
36
|
|
40
37
|
def appcmd(value)
|
41
|
-
Helper.validates_presence_of @url,
|
42
|
-
Helper.validates_presence_of @protocol,
|
38
|
+
Helper.validates_presence_of @url, 'IIS URL not set'
|
39
|
+
Helper.validates_presence_of @protocol, 'Protocol not set'
|
43
40
|
|
44
41
|
begin
|
45
42
|
uri = URI(@protocol + '://' + @url)
|
@@ -54,17 +51,17 @@ module Publisher
|
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
57
|
-
rescue
|
58
|
-
$log.writer.error
|
59
|
-
$log.writer.error "Request was: #{uri
|
54
|
+
rescue => e
|
55
|
+
$log.writer.error 'Error: while connecting to IIS Server'
|
56
|
+
$log.writer.error "Request was: #{uri}"
|
60
57
|
$log.writer.error e.message
|
61
58
|
exit 1
|
62
59
|
end
|
63
60
|
end
|
64
61
|
|
65
|
-
|
66
|
-
Helper.validates_presence_of @url,
|
67
|
-
Helper.validates_presence_of @protocol,
|
62
|
+
def deploy(version, iis_application_name, env)
|
63
|
+
Helper.validates_presence_of @url, 'IIS URL not set'
|
64
|
+
Helper.validates_presence_of @protocol, 'Protocol not set'
|
68
65
|
iis_error = false
|
69
66
|
|
70
67
|
begin
|
@@ -76,26 +73,22 @@ module Publisher
|
|
76
73
|
request.content_type = 'application/x-www-form-urlencoded;charset=utf-8'
|
77
74
|
http.request request do |response|
|
78
75
|
response.read_body do |chunk|
|
79
|
-
if chunk.include?(
|
80
|
-
$log.writer.error
|
76
|
+
if chunk.include?('### Error while executing')
|
77
|
+
$log.writer.error 'Error executing deploy on IIS'
|
81
78
|
iis_error = true
|
82
79
|
end
|
83
80
|
$log.writer.info "#{chunk}"
|
84
81
|
end
|
85
82
|
end
|
86
83
|
end
|
87
|
-
rescue
|
88
|
-
$log.writer.error
|
89
|
-
$log.writer.error "Request was: #{uri
|
84
|
+
rescue => e
|
85
|
+
$log.writer.error 'Error: while connecting to IIS Server'
|
86
|
+
$log.writer.error "Request was: #{uri}"
|
90
87
|
$log.writer.error e.message
|
91
88
|
exit 1
|
92
89
|
end
|
93
90
|
|
94
|
-
if iis_error
|
95
|
-
exit 1
|
96
|
-
end
|
97
|
-
|
91
|
+
fail if iis_error
|
98
92
|
end
|
99
|
-
|
100
93
|
end
|
101
|
-
end
|
94
|
+
end
|
@@ -4,20 +4,19 @@ module Publisher
|
|
4
4
|
attr_accessor :remote_user
|
5
5
|
attr_accessor :ssh_key_file
|
6
6
|
|
7
|
-
def sync(source, target, options={})
|
7
|
+
def sync(source, target, options = {})
|
8
8
|
# default options
|
9
|
-
command_options = [
|
9
|
+
command_options = ['-a']
|
10
10
|
if options[:local].nil? or options[:local] == false
|
11
|
-
Helper.validates_presence_of remote_host,
|
12
|
-
Helper.validates_presence_of remote_user,
|
13
|
-
Helper.validates_presence_of ssh_key_file,
|
11
|
+
Helper.validates_presence_of remote_host, 'Remote Host not set'
|
12
|
+
Helper.validates_presence_of remote_user, 'Remote User not set'
|
13
|
+
Helper.validates_presence_of ssh_key_file, 'SSH-Keyfile not set'
|
14
14
|
|
15
15
|
target = "#{remote_user}@#{remote_host}:" + target
|
16
16
|
command_options << "-e \'ssh -c arcfour -o StrictHostKeyChecking=no -i #{ssh_key_file}\'"
|
17
17
|
end
|
18
18
|
|
19
19
|
rsync = options[:rsync_bin] || 'rsync'
|
20
|
-
result = ''
|
21
20
|
|
22
21
|
if not options[:delete].nil? and options[:delete] == true
|
23
22
|
command_options << '--delete'
|
@@ -25,7 +24,7 @@ module Publisher
|
|
25
24
|
if not options[:whole_file].nil? and options[:whole_file] == true
|
26
25
|
command_options << '-W'
|
27
26
|
end
|
28
|
-
|
27
|
+
unless options[:rsync_path].nil?
|
29
28
|
command_options << "--rsync-path=#{options[:rsync_path]}"
|
30
29
|
end
|
31
30
|
if options[:one_filesystem].nil? or options[:one_filesystem] == true
|
@@ -34,11 +33,10 @@ module Publisher
|
|
34
33
|
if options[:compression].nil? or options[:compression] == true
|
35
34
|
command_options << '-z'
|
36
35
|
end
|
37
|
-
|
36
|
+
unless options[:exclude].nil?
|
38
37
|
[options[:exclude]].flatten.each do |current_exclude|
|
39
|
-
|
40
|
-
|
41
|
-
end
|
38
|
+
next unless current_exclude > ''
|
39
|
+
command_options << "--exclude #{current_exclude}"
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
@@ -47,16 +45,16 @@ module Publisher
|
|
47
45
|
# options[:whole_file] default false
|
48
46
|
# options[:one_filesystem] default true
|
49
47
|
# options[:compression] default true
|
50
|
-
#
|
48
|
+
# TODO: ssh-agent preload key with passphrase
|
51
49
|
begin
|
52
50
|
$log.writer.debug "#{rsync} #{command_options.join(' ')} #{source} #{target}"
|
53
|
-
stdout =
|
51
|
+
stdout = `#{rsync} #{command_options.join(' ')} \"#{source}\" \"#{target}\"`
|
54
52
|
$log.writer.debug stdout
|
55
53
|
|
56
|
-
|
57
|
-
|
54
|
+
unless RUBY_VERSION < '1.9'
|
55
|
+
fail 'rsync execution error' if $CHILD_STATUS.exitstatus != 0
|
58
56
|
end
|
59
|
-
rescue
|
57
|
+
rescue => e
|
60
58
|
$log.writer.error "Can not sync directory #{source} with #{target}"
|
61
59
|
$log.writer.error e.message
|
62
60
|
$log.writer.error e.backtrace.join("\n")
|
@@ -65,4 +63,3 @@ module Publisher
|
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
68
|
-
|
@@ -5,19 +5,19 @@ module Publisher
|
|
5
5
|
attr_accessor :samba_mountpoints
|
6
6
|
attr_accessor :worker
|
7
7
|
|
8
|
-
def copy(source, target,
|
9
|
-
Helper.validates_presence_of samba_mountpoints,
|
10
|
-
Helper.validates_presence_of samba_share,
|
8
|
+
def copy(source, target, _options = {})
|
9
|
+
Helper.validates_presence_of samba_mountpoints, 'Samba mountpoints not set'
|
10
|
+
Helper.validates_presence_of samba_share, 'Samba Share not set'
|
11
11
|
|
12
12
|
begin
|
13
13
|
begin
|
14
14
|
# mount
|
15
|
-
worker.samba_mount(samba_share,"#{samba_mountpoints}/#{samba_share}")
|
15
|
+
worker.samba_mount(samba_share, "#{samba_mountpoints}/#{samba_share}")
|
16
16
|
|
17
17
|
to = "#{samba_mountpoints}/#{samba_share}/#{target}"
|
18
18
|
### create target directory
|
19
|
-
|
20
|
-
|
19
|
+
unless File.directory?(to)
|
20
|
+
unless FileUtils.mkdir_p(to)
|
21
21
|
$log.writer.error "Unable to create target directory #{to}"
|
22
22
|
exit 1
|
23
23
|
end
|
@@ -27,7 +27,7 @@ module Publisher
|
|
27
27
|
shell_cmd = "rsync -a --delete #{source} #{to}"
|
28
28
|
$log.writer.debug "Execute command: #{shell_cmd}"
|
29
29
|
output = system shell_cmd
|
30
|
-
|
30
|
+
unless output
|
31
31
|
$log.writer.error "#{method} #{shell_cmd} failed"
|
32
32
|
exit 1
|
33
33
|
end
|
@@ -36,27 +36,25 @@ module Publisher
|
|
36
36
|
# umount
|
37
37
|
worker.samba_umount("#{samba_mountpoints}/#{samba_share}")
|
38
38
|
|
39
|
-
rescue
|
40
|
-
$log.writer.error
|
39
|
+
rescue => e
|
40
|
+
$log.writer.error 'Can not publish files using samba'
|
41
41
|
$log.writer.error e.message
|
42
42
|
$log.writer.error e.backtrace.join("\n")
|
43
43
|
worker.samba_umount("#{samba_mountpoints}/#{samba_share}")
|
44
44
|
exit 1
|
45
45
|
end
|
46
46
|
|
47
|
-
rescue
|
47
|
+
rescue => e
|
48
48
|
$log.writer.error "Can not upload files to #{target}"
|
49
49
|
$log.writer.error e.message
|
50
50
|
$log.writer.error e.backtrace.join("\n")
|
51
51
|
exit 1
|
52
52
|
end
|
53
|
-
|
54
53
|
end
|
55
54
|
|
56
|
-
def chmod(
|
57
|
-
$log.writer.fatal
|
55
|
+
def chmod(_path, _permissions, _options = {})
|
56
|
+
$log.writer.fatal 'Not yet implemented'
|
58
57
|
exit 1
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
62
|
-
|