depengine 3.0.20 → 3.0.21
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/.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
@@ -3,47 +3,47 @@ module Provider
|
|
3
3
|
attr_accessor :repository_url
|
4
4
|
attr_accessor :repository_local_dir
|
5
5
|
|
6
|
-
def fetch(
|
7
|
-
Helper.validates_presence_of repository_url,
|
8
|
-
Helper.validates_presence_of repository_local_dir,
|
6
|
+
def fetch(_options = {})
|
7
|
+
Helper.validates_presence_of repository_url, 'repository_url not set'
|
8
|
+
Helper.validates_presence_of repository_local_dir, 'repository_local_dir not set'
|
9
9
|
|
10
10
|
# Make sure directory exists
|
11
|
-
|
11
|
+
unless File.exist? repository_local_dir
|
12
12
|
FileUtils.mkdir_p(repository_local_dir)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Fetch (or clone)
|
16
16
|
Dir.chdir(repository_local_dir) do
|
17
|
-
if
|
18
|
-
$log.writer.info
|
17
|
+
if !File.exist? '.git'
|
18
|
+
$log.writer.info 'Clone git repository'
|
19
19
|
shell_cmd = "git clone #{repository_url} ."
|
20
20
|
output = system shell_cmd
|
21
|
-
|
21
|
+
unless output
|
22
22
|
current_directory = Dir.getwd
|
23
23
|
$log.writer.error "Unable to clone repository #{repository_url} into #{current_directory}"
|
24
24
|
exit 1
|
25
25
|
end
|
26
26
|
else
|
27
|
-
$log.writer.info
|
28
|
-
shell_cmd =
|
27
|
+
$log.writer.info 'Fetch git repository'
|
28
|
+
shell_cmd = 'git fetch origin'
|
29
29
|
output = system shell_cmd
|
30
|
-
|
31
|
-
$log.writer.error
|
30
|
+
unless output
|
31
|
+
$log.writer.error 'Unable to fetch from origin'
|
32
32
|
exit 1
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def checkout(branch_name,
|
39
|
-
Helper.validates_presence_of repository_url,
|
40
|
-
Helper.validates_presence_of repository_local_dir,
|
38
|
+
def checkout(branch_name, _options = {})
|
39
|
+
Helper.validates_presence_of repository_url, 'repository_url not set'
|
40
|
+
Helper.validates_presence_of repository_local_dir, 'repository_local_dir not set'
|
41
41
|
|
42
42
|
Dir.chdir(repository_local_dir) do
|
43
43
|
# Pull
|
44
|
-
shell_cmd =
|
44
|
+
shell_cmd = 'git pull origin master'
|
45
45
|
output = system shell_cmd
|
46
|
-
|
46
|
+
unless output
|
47
47
|
$log.writer.error "Unable to pull branch #{branch_name}"
|
48
48
|
exit 1
|
49
49
|
end
|
@@ -51,56 +51,53 @@ module Provider
|
|
51
51
|
# Checkout
|
52
52
|
shell_cmd = "git checkout -f #{branch_name}"
|
53
53
|
output = system shell_cmd
|
54
|
-
|
54
|
+
unless output
|
55
55
|
$log.writer.error "Unable to checkout branch #{branch_name}"
|
56
56
|
exit 1
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def submodule(submodule_option,
|
62
|
-
Helper.validates_presence_of repository_url,
|
63
|
-
Helper.validates_presence_of repository_local_dir,
|
61
|
+
def submodule(submodule_option, _options = {})
|
62
|
+
Helper.validates_presence_of repository_url, 'repository_url not set'
|
63
|
+
Helper.validates_presence_of repository_local_dir, 'repository_local_dir not set'
|
64
64
|
|
65
65
|
Dir.chdir(repository_local_dir) do
|
66
66
|
# Submodule init
|
67
|
-
shell_cmd =
|
68
|
-
|
69
|
-
|
67
|
+
shell_cmd = 'git submodule init'
|
68
|
+
system(shell_cmd)
|
69
|
+
|
70
70
|
# git submodule update --recursive
|
71
71
|
shell_cmd = "git submodule update #{submodule_option}"
|
72
72
|
output = system shell_cmd
|
73
|
-
|
74
|
-
$log.writer.error
|
73
|
+
unless output
|
74
|
+
$log.writer.error 'Unable to pull submodule'
|
75
75
|
exit 1
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
Helper.validates_presence_of
|
83
|
-
Helper.validates_presence_of repository_local_dir, "repository_local_dir not set"
|
80
|
+
def tag(tag_name, options = {})
|
81
|
+
Helper.validates_presence_of repository_url, 'repository_url not set'
|
82
|
+
Helper.validates_presence_of repository_local_dir, 'repository_local_dir not set'
|
84
83
|
|
85
84
|
Dir.chdir(repository_local_dir) do
|
86
85
|
# Create tag
|
87
86
|
shell_cmd = "git tag #{tag_name}"
|
88
|
-
|
89
|
-
shell_cmd << " #{options[:hash]}"
|
90
|
-
end
|
87
|
+
shell_cmd << " #{options[:hash]}" if options[:hash]
|
91
88
|
|
92
89
|
output = system shell_cmd
|
93
|
-
|
90
|
+
unless output
|
94
91
|
$log.writer.error "Unable to create tag #{tag_name}"
|
95
|
-
|
92
|
+
fail "Unable to create tag #{tag_name}"
|
96
93
|
end
|
97
94
|
|
98
95
|
# Push tag
|
99
|
-
shell_cmd =
|
96
|
+
shell_cmd = 'git push -f --tags origin'
|
100
97
|
output = system shell_cmd
|
101
|
-
|
102
|
-
$log.writer.error
|
103
|
-
|
98
|
+
unless output
|
99
|
+
$log.writer.error 'Unable to push to origin'
|
100
|
+
fail 'Unable to push to origin'
|
104
101
|
end
|
105
102
|
end
|
106
103
|
end
|
@@ -111,14 +108,12 @@ module Provider
|
|
111
108
|
# * +:r2+ - Include commits that are reachable from r2
|
112
109
|
# * +:r1+ - but exclude those that are reachable from r1.
|
113
110
|
# Please see `GITREVISIONS(7)` for more info on how to specify a revision range.
|
114
|
-
def history(r1='',r2='HEAD')
|
111
|
+
def history(r1 = '', r2 = 'HEAD')
|
115
112
|
rev_range = r1.empty? ? '' : "#{r1}..#{r2}"
|
116
113
|
|
117
114
|
Dir.chdir(@repository_local_dir) do
|
118
115
|
Processor.local_execute(["git log --oneline #{rev_range}"])
|
119
116
|
end
|
120
117
|
end
|
121
|
-
|
122
118
|
end
|
123
119
|
end
|
124
|
-
|
@@ -1,202 +1,187 @@
|
|
1
1
|
module Provider
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
samba_mountpoints = ""
|
2
|
+
class Repository
|
3
|
+
attr_accessor :repository
|
4
|
+
attr_accessor :worker
|
5
|
+
attr_accessor :method
|
6
|
+
attr_accessor :user
|
7
|
+
attr_accessor :password
|
8
|
+
attr_accessor :host
|
9
|
+
attr_accessor :sshkey
|
10
|
+
attr_accessor :svnbinary
|
11
|
+
attr_accessor :svncmd
|
12
|
+
attr_accessor :samba_mountpoints
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@repository = ''
|
16
|
+
@method = ''
|
17
|
+
@user = ''
|
18
|
+
@password = ''
|
19
|
+
@host = ''
|
20
|
+
@sshkey = ''
|
21
|
+
@svnbinary = ''
|
22
|
+
@svncmd = ''
|
23
|
+
@samba_mountpoints = ''
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
26
|
+
def get_from_maven(from, to)
|
27
|
+
response = nil
|
28
|
+
req = nil
|
29
|
+
target = to
|
30
|
+
string_array = from.split('/')
|
31
|
+
file_name = string_array[string_array.length - 1]
|
32
|
+
target = target << '/' if target[target.length - 1, 1] != '/'
|
33
|
+
target = target + file_name
|
34
|
+
|
35
|
+
#### create target directory
|
36
|
+
unless File.directory?(to)
|
37
|
+
unless FileUtils.mkdir_p(to)
|
38
|
+
$log.writer.error "Unable to create directory #{to}"
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
url = URI.parse(repository + from)
|
44
|
+
http = Net::HTTP.new(url.host, url.port)
|
45
|
+
if url.scheme == 'https'
|
46
|
+
http.use_ssl = true
|
47
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
48
|
+
end
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
begin
|
51
|
+
http.start do |connection|
|
52
|
+
req = Net::HTTP::Get.new(url.path)
|
53
|
+
# req.basic_auth user, password
|
54
|
+
response = connection.request(req)
|
55
|
+
body = response.body
|
56
|
+
|
57
|
+
case response
|
58
|
+
when Net::HTTPSuccess
|
59
|
+
# OK
|
60
|
+
File.open(target, 'w') { |f| f.write body }
|
61
|
+
else
|
62
|
+
$log.writer.error 'Can not get file from ' + url.scheme + '://' + url.host + url.path
|
47
63
|
exit 1
|
48
64
|
end
|
49
65
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
# OK
|
67
|
-
File.open(target, 'w') {|f|
|
68
|
-
f.write body
|
69
|
-
}
|
70
|
-
else
|
71
|
-
$log.writer.error "Can not get file from " + url.scheme + "://" + url.host + url.path
|
72
|
-
exit 1
|
73
|
-
end
|
74
|
-
end
|
75
|
-
rescue Exception => e
|
76
|
-
$log.writer.error "Can not make a HTTP connection to #{url.host}"
|
66
|
+
rescue
|
67
|
+
$log.writer.error "Can not make a HTTP connection to #{url.host}"
|
68
|
+
exit 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_from_scp(from, to)
|
73
|
+
unless File.file? sshkey
|
74
|
+
$log.writer.error "Keyfile #{File.expand_path sshkey} does not exists"
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
|
78
|
+
#### create target directory
|
79
|
+
unless File.directory?(to)
|
80
|
+
unless FileUtils.mkdir_p(to)
|
81
|
+
$log.writer.error "Unable to create directory #{to}"
|
77
82
|
exit 1
|
78
83
|
end
|
79
|
-
|
84
|
+
end
|
80
85
|
|
81
|
-
|
82
|
-
|
86
|
+
begin
|
87
|
+
Net::SCP.start(host, user, keys: [sshkey], host_key: 'ssh-rsa', auth_methods: ['publickey']) do |scp|
|
88
|
+
scp.download!(from, to, recursive: true)
|
89
|
+
end
|
90
|
+
rescue => e
|
91
|
+
$log.writer.error "Can not copy #{host}:#{from} to #{to}"
|
92
|
+
$log.writer.error e.message
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
end
|
83
96
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
97
|
+
def get_from_svn(from, to)
|
98
|
+
### svn command not set
|
99
|
+
if svncmd.empty?
|
100
|
+
$log.writer.error 'No svn command defined'
|
101
|
+
exit 1
|
102
|
+
end
|
88
103
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
### get from svn
|
109
|
-
if method == "svn"
|
110
|
-
|
111
|
-
### svn command not set
|
112
|
-
if svncmd.empty?
|
113
|
-
$log.writer.error "No svn command defined"
|
104
|
+
### get svn info (file or directory
|
105
|
+
shell_cmd = create_svn_cmd('info', from, '')
|
106
|
+
output = `#{shell_cmd}`
|
107
|
+
doc = REXML::Document.new output
|
108
|
+
root = doc.root
|
109
|
+
target = to
|
110
|
+
if root.elements['/info/entry'].attributes['kind'] == 'fil e'
|
111
|
+
string_array = from.split('/ ')
|
112
|
+
file_name = string_array[string_array.length - 1]
|
113
|
+
target = target << '/' if target[target.length - 1, 1] != ' /'
|
114
|
+
target = target + file_name
|
115
|
+
end
|
116
|
+
|
117
|
+
#### create target directory
|
118
|
+
unless File.directory?(to)
|
119
|
+
unless FileUtils.mkdir_p(to)
|
120
|
+
$log.writer.error "Unable to create directory #{to}"
|
114
121
|
exit 1
|
115
122
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
if not FileUtils.mkdir_p(to)
|
133
|
-
$log.writer.error "Unable to create directory #{to}"
|
134
|
-
exit 1
|
135
|
-
end
|
123
|
+
end
|
124
|
+
|
125
|
+
shell_cmd = create_svn_cmd(svncmd, from, target)
|
126
|
+
$log.writer.debug "Execute command: #{shell_cmd}"
|
127
|
+
output = system shell_cmd
|
128
|
+
return if output
|
129
|
+
$log.writer.error "svn #{svncmd} failed"
|
130
|
+
fail "svn #{svncmd} failed"
|
131
|
+
end
|
132
|
+
|
133
|
+
def get_from_samba(from, to)
|
134
|
+
#### create target directory
|
135
|
+
unless File.directory?(to)
|
136
|
+
unless FileUtils.mkdir_p(to)
|
137
|
+
$log.writer.error "Unable to create target directory #{to}"
|
138
|
+
fail "Unable to create target directory #{to}"
|
136
139
|
end
|
137
|
-
|
138
|
-
|
140
|
+
end
|
141
|
+
begin
|
142
|
+
worker.samba_mount(repository, "#{samba_mountpoints}/#{repository}")
|
143
|
+
|
144
|
+
# local rsync
|
145
|
+
shell_cmd = "rsync -va --delete #{samba_mountpoints}/#{repository}/#{from}/ #{to}"
|
139
146
|
$log.writer.debug "Execute command: #{shell_cmd}"
|
140
147
|
output = system shell_cmd
|
141
|
-
|
142
|
-
$log.writer.error "
|
143
|
-
|
148
|
+
unless output
|
149
|
+
$log.writer.error "#{method} #{shell_cmd} failed"
|
150
|
+
fail "#{method} #{shell_cmd} failed"
|
144
151
|
end
|
152
|
+
$log.writer.info output
|
145
153
|
|
146
|
-
|
147
|
-
|
148
|
-
#### create target directory
|
149
|
-
if not File.directory?(to)
|
150
|
-
if not FileUtils.mkdir_p(to)
|
151
|
-
$log.writer.error "Unable to create target directory #{to}"
|
152
|
-
exit 1
|
153
|
-
end
|
154
|
-
end
|
155
|
-
begin
|
156
|
-
worker.samba_mount(repository,"#{samba_mountpoints}/#{repository}")
|
157
|
-
|
158
|
-
# local rsync
|
159
|
-
shell_cmd = "rsync -va --delete #{samba_mountpoints}/#{repository}/#{from}/ #{to}"
|
160
|
-
$log.writer.debug "Execute command: #{shell_cmd}"
|
161
|
-
output = system shell_cmd
|
162
|
-
if not output
|
163
|
-
$log.writer.error "#{method} #{shell_cmd} failed"
|
164
|
-
exit 1
|
165
|
-
end
|
166
|
-
$log.writer.info output
|
167
|
-
|
168
|
-
# umount
|
169
|
-
worker.samba_umount("#{samba_mountpoints}/#{repository}")
|
170
|
-
|
171
|
-
rescue Exception => e
|
172
|
-
$log.writer.error "Can not provide files using #{method}"
|
173
|
-
$log.writer.error e.message
|
174
|
-
$log.writer.error e.backtrace.join("\n")
|
175
|
-
worker.samba_umount("#{samba_mountpoints}/#{repository}")
|
176
|
-
exit 1
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
154
|
+
# umount
|
155
|
+
worker.samba_umount("#{samba_mountpoints}/#{repository}")
|
180
156
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
157
|
+
rescue => e
|
158
|
+
$log.writer.error "Can not provide files using #{method}"
|
159
|
+
$log.writer.error e.message
|
160
|
+
$log.writer.error e.backtrace.join("\n")
|
161
|
+
worker.samba_umount("#{samba_mountpoints}/#{repository}")
|
162
|
+
exit 1
|
163
|
+
end
|
164
|
+
end
|
187
165
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
166
|
+
def get_from_repository(from, to)
|
167
|
+
get_from_maven(from, to) if method == 'maven'
|
168
|
+
get_from_scp(from, to) if method == 'scp'
|
169
|
+
get_from_svn(from, to) if method == 'svn'
|
170
|
+
get_from_samba(from, to) if method == 'samba'
|
171
|
+
end
|
172
|
+
|
173
|
+
def create_svn_cmd(svncmd, from, target)
|
174
|
+
shell_cmd = svnbinary + ' ' + svncmd
|
175
|
+
shell_cmd = shell_cmd + ' --force' if svncmd == 'checkout' or svncmd == 'export'
|
176
|
+
shell_cmd = shell_cmd + ' --xml' if svncmd == 'info'
|
192
177
|
|
193
|
-
|
194
|
-
|
195
|
-
|
178
|
+
if not user.empty? and not password.empty?
|
179
|
+
shell_cmd = shell_cmd + ' --username ' + user + \
|
180
|
+
' --password ' + password
|
196
181
|
end
|
197
|
-
return shell_cmd
|
198
|
-
end
|
199
182
|
|
183
|
+
shell_cmd = shell_cmd + ' ' + repository + '/' + from
|
184
|
+
shell_cmd = shell_cmd + ' ' + target.to_s if svncmd =~ /^checkout/ or svncmd =~ /^export/ # rubocop:disable Lint/UselessAssignment
|
185
|
+
end
|
200
186
|
end
|
201
187
|
end
|
202
|
-
|