depengine 3.0.12 → 3.0.13
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/Gemfile.lock +2 -2
- data/README.md +38 -2
- data/Rakefile +5 -0
- data/lib/depengine/cli.rb +5 -1
- data/lib/depengine/dsl/deployment.rb +31 -11
- data/lib/depengine/dsl/fileops.rb +22 -0
- data/lib/depengine/dsl/helper.rb +81 -14
- data/lib/depengine/dsl/iis.rb +9 -9
- data/lib/depengine/dsl/patch.rb +3 -13
- data/lib/depengine/dsl/repository.rb +4 -4
- data/lib/depengine/dsl/template.rb +4 -2
- data/lib/depengine/helper/mail.rb +12 -5
- data/lib/depengine/helper/validations.rb +15 -0
- data/lib/depengine/processor/properties.rb +0 -7
- data/lib/depengine/processor/template.rb +64 -49
- data/lib/depengine/{publisher → provider}/git.rb +1 -1
- data/lib/depengine/publisher/iis.rb +101 -0
- data/lib/depengine/reporter/cdb.rb +1 -1
- data/lib/depengine/version.rb +1 -1
- data/spec/cdb_spec.rb +0 -14
- data/spec/demo_recipe/bin/.gitkeep +0 -0
- data/spec/demo_recipe/cdb/.gitkeep +0 -0
- data/spec/demo_recipe/config/config.properties +5 -0
- data/spec/demo_recipe/recipes/demo.rb +27 -0
- data/spec/helper_spec.rb +127 -0
- data/spec/template_spec.rb +82 -29
- metadata +12 -9
- data/lib/depengine/publisher/iis_appcmd.rb +0 -33
- data/lib/depengine/publisher/iis_build.rb +0 -43
- data/lib/depengine/publisher/iis_deploy.rb +0 -43
- data/lib/depengine/reporter/mail.rb +0 -28
- data/spec/mail_spec.rb +0 -25
data/spec/template_spec.rb
CHANGED
@@ -2,51 +2,104 @@ require 'rubygems'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'radius'
|
4
4
|
require 'log4r'
|
5
|
+
require 'find'
|
6
|
+
require 'tmpdir'
|
5
7
|
require_relative '../lib/depengine/processor/tags'
|
6
8
|
require_relative '../lib/depengine/processor/template'
|
7
9
|
require_relative '../lib/depengine/log/log'
|
10
|
+
require_relative '../lib/depengine/dsl/template'
|
11
|
+
require_relative '../lib/depengine/helper/validations'
|
8
12
|
|
9
|
-
$log
|
13
|
+
$log = Log::DeploymentLogger.new
|
10
14
|
$log.writer.level = Log4r::ERROR
|
11
15
|
|
12
|
-
describe "the
|
13
|
-
it "should render a template from a string" do
|
14
|
-
result = Processor::Template.parse(">Template< ><t:echo>Content</t:echo><", {})
|
15
|
-
result.should include(">Template< >Content<")
|
16
|
-
end
|
16
|
+
describe "the template mechanism" do
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
context "given a string" do
|
19
|
+
it "should render a template" do
|
20
|
+
result = Processor::Template.parse(">Template< ><t:echo>Content</t:echo><", {})
|
21
|
+
expect(result).to include(">Template< >Content<")
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
context "given a single file as source" do
|
26
|
+
it "should render a template" do
|
27
|
+
result = Processor::Template.parse('spec/templates/single.tpl', {})
|
28
|
+
expect(result).to include(">Template< >Content<")
|
29
|
+
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
it "should create Tags from the content hash and provide it to the template" do
|
32
|
+
content = {'parameter' => 'value'}
|
33
|
+
result = Processor::Template.parse('spec/templates/single_hash.tpl', content)
|
34
|
+
expect(result).to include(">Template< >value<")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should honor the excludes" do
|
38
|
+
tmp_dir = Dir.mktmpdir
|
39
|
+
begin
|
40
|
+
worker = Processor::Template.new
|
41
|
+
worker.basepath = File.join(File.dirname(__FILE__), 'templates')
|
42
|
+
worker.parse_template('base/sub1/single.tpl', {}, tmp_dir, {:excludes => ["single"]})
|
34
43
|
|
35
|
-
|
36
|
-
|
44
|
+
expect(File.file?(File.join(tmp_dir, "base/sub1/single"))).to be false
|
45
|
+
ensure
|
46
|
+
FileUtils.remove_entry tmp_dir
|
47
|
+
end
|
37
48
|
end
|
38
|
-
end
|
39
49
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
50
|
+
it "should create a directory structure in analogy to the source tree" do
|
51
|
+
tmp_dir = Dir.mktmpdir
|
52
|
+
begin
|
53
|
+
worker = Processor::Template.new
|
54
|
+
worker.basepath = File.join(File.dirname(__FILE__), 'templates')
|
55
|
+
worker.parse_template('base/sub1/single.tpl', {}, tmp_dir)
|
45
56
|
|
46
|
-
|
47
|
-
|
57
|
+
expect(File.open(File.join(tmp_dir,"base/sub1/single"), 'r').read).to include(">Template< >Content<")
|
58
|
+
ensure
|
59
|
+
FileUtils.remove_entry tmp_dir
|
60
|
+
end
|
48
61
|
end
|
49
62
|
end
|
50
63
|
|
64
|
+
context "given a directory" do
|
65
|
+
it "should create a directory structure in analogy to the source tree" do
|
66
|
+
tmp_dir = Dir.mktmpdir
|
67
|
+
begin
|
68
|
+
worker = Processor::Template.new
|
69
|
+
worker.basepath = File.join(File.dirname(__FILE__), 'templates')
|
70
|
+
worker.parse_template('base/sub2', {}, tmp_dir)
|
71
|
+
|
72
|
+
expect(File.open(File.join(tmp_dir, "base/sub2/multi2"), 'r').read).to include(">Template< >Content<")
|
73
|
+
ensure
|
74
|
+
FileUtils.remove_entry tmp_dir
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not use any excluded file" do
|
79
|
+
tmp_dir = Dir.mktmpdir
|
80
|
+
begin
|
81
|
+
worker = Processor::Template.new
|
82
|
+
worker.basepath = File.join(File.dirname(__FILE__), 'templates')
|
83
|
+
worker.parse_template('base/sub2', {}, tmp_dir, {:excludes => ["multi2"]})
|
84
|
+
|
85
|
+
expect(File.file?(File.join(tmp_dir, "base/sub2/multi2"))).to be false
|
86
|
+
expect(File.file?(File.join(tmp_dir, "base/sub2/multi1"))).to be true
|
87
|
+
ensure
|
88
|
+
FileUtils.remove_entry tmp_dir
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
51
92
|
end
|
52
93
|
|
94
|
+
describe "the template DSL method 'parse_template'" do
|
95
|
+
it "calls the processor" do
|
96
|
+
tmp_dir = Dir.mktmpdir
|
97
|
+
begin
|
98
|
+
hack_object = Class.new.class.class_eval("include Deployment::Methods::Template")
|
99
|
+
hack_object.parse_template("base/sub1/single.tpl", tmp_dir, {}, {:basepath => File.join(File.dirname(__FILE__), 'templates'), })
|
100
|
+
ensure
|
101
|
+
FileUtils.remove_entry tmp_dir
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depengine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Automatisierung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -232,12 +232,10 @@ files:
|
|
232
232
|
- lib/depengine/processor/zip.rb
|
233
233
|
- lib/depengine/provider/cdb.rb
|
234
234
|
- lib/depengine/provider/cdb_filesystem.rb
|
235
|
+
- lib/depengine/provider/git.rb
|
235
236
|
- lib/depengine/provider/repository.rb
|
236
237
|
- lib/depengine/publisher/dweb.rb
|
237
|
-
- lib/depengine/publisher/
|
238
|
-
- lib/depengine/publisher/iis_appcmd.rb
|
239
|
-
- lib/depengine/publisher/iis_build.rb
|
240
|
-
- lib/depengine/publisher/iis_deploy.rb
|
238
|
+
- lib/depengine/publisher/iis.rb
|
241
239
|
- lib/depengine/publisher/rsync.rb
|
242
240
|
- lib/depengine/publisher/samba.rb
|
243
241
|
- lib/depengine/publisher/sftp.rb
|
@@ -245,14 +243,16 @@ files:
|
|
245
243
|
- lib/depengine/publisher/tomcat.rb
|
246
244
|
- lib/depengine/reporter/cdb.rb
|
247
245
|
- lib/depengine/reporter/log4j.rb
|
248
|
-
- lib/depengine/reporter/mail.rb
|
249
246
|
- lib/depengine/version.rb
|
250
247
|
- spec/cdb_spec.rb
|
248
|
+
- spec/demo_recipe/bin/.gitkeep
|
249
|
+
- spec/demo_recipe/cdb/.gitkeep
|
250
|
+
- spec/demo_recipe/config/config.properties
|
251
|
+
- spec/demo_recipe/recipes/demo.rb
|
251
252
|
- spec/deployhelper_spec.rb
|
252
253
|
- spec/fileops_spec.rb
|
253
254
|
- spec/helper_spec.rb
|
254
255
|
- spec/log_spec.rb
|
255
|
-
- spec/mail_spec.rb
|
256
256
|
- spec/properties/source/config.properties
|
257
257
|
- spec/properties/source/random.rb
|
258
258
|
- spec/properties/target/.gitkeep
|
@@ -295,11 +295,14 @@ specification_version: 4
|
|
295
295
|
summary: Depengine generator
|
296
296
|
test_files:
|
297
297
|
- spec/cdb_spec.rb
|
298
|
+
- spec/demo_recipe/bin/.gitkeep
|
299
|
+
- spec/demo_recipe/cdb/.gitkeep
|
300
|
+
- spec/demo_recipe/config/config.properties
|
301
|
+
- spec/demo_recipe/recipes/demo.rb
|
298
302
|
- spec/deployhelper_spec.rb
|
299
303
|
- spec/fileops_spec.rb
|
300
304
|
- spec/helper_spec.rb
|
301
305
|
- spec/log_spec.rb
|
302
|
-
- spec/mail_spec.rb
|
303
306
|
- spec/properties/source/config.properties
|
304
307
|
- spec/properties/source/random.rb
|
305
308
|
- spec/properties/target/.gitkeep
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Publisher
|
2
|
-
class Iis_appcmd
|
3
|
-
attr_accessor :iis_appcmd_url
|
4
|
-
attr_accessor :iis_appcmd_protocol
|
5
|
-
attr_accessor :http_read_timeout
|
6
|
-
|
7
|
-
def appcmd(value)
|
8
|
-
Helper.validates_presence_of iis_appcmd_url, "IIS URL not set"
|
9
|
-
Helper.validates_presence_of iis_appcmd_protocol, "Protocol not set"
|
10
|
-
|
11
|
-
begin
|
12
|
-
uri = URI(iis_appcmd_protocol + '://' + iis_appcmd_url)
|
13
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
14
|
-
http.read_timeout = http_read_timeout
|
15
|
-
request = Net::HTTP::Post.new uri.request_uri
|
16
|
-
request.set_form_data('value' => value)
|
17
|
-
request.content_type = 'application/x-www-form-urlencoded;charset=utf-8'
|
18
|
-
http.request request do |response|
|
19
|
-
response.read_body do |chunk|
|
20
|
-
$log.writer.info "#{chunk}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
rescue Exception => e
|
25
|
-
$log.writer.error "Error: while connecting to IIS Server"
|
26
|
-
$log.writer.error "Request was: #{uri.to_s}"
|
27
|
-
$log.writer.error e.message
|
28
|
-
exit 1
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Publisher
|
2
|
-
class Iis_build
|
3
|
-
attr_accessor :iis_build_url
|
4
|
-
attr_accessor :iis_build_protocol
|
5
|
-
attr_accessor :http_read_timeout
|
6
|
-
|
7
|
-
def build(tag, env, version, value, application_name)
|
8
|
-
Helper.validates_presence_of iis_build_url, "IIS URL not set"
|
9
|
-
Helper.validates_presence_of iis_build_protocol, "Protocol not set"
|
10
|
-
iis_error = false
|
11
|
-
|
12
|
-
begin
|
13
|
-
uri = URI(iis_build_protocol + '://' + iis_build_url)
|
14
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
15
|
-
http.read_timeout = http_read_timeout
|
16
|
-
request = Net::HTTP::Post.new uri.request_uri
|
17
|
-
request.set_form_data('tag' => tag, 'env' => env, 'version' => version, 'value' => value, 'application_name' => application_name)
|
18
|
-
request.content_type = 'application/x-www-form-urlencoded;charset=utf-8'
|
19
|
-
http.request request do |response|
|
20
|
-
response.read_body do |chunk|
|
21
|
-
if chunk.include?("### Error while executing")
|
22
|
-
$log.writer.error "Error executing build on IIS"
|
23
|
-
iis_error = true
|
24
|
-
end
|
25
|
-
$log.writer.info "#{chunk}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
rescue Exception => e
|
30
|
-
$log.writer.error "Error: while connecting to IIS Server"
|
31
|
-
$log.writer.error "Request was: #{uri.to_s}"
|
32
|
-
$log.writer.error e.message
|
33
|
-
exit 1
|
34
|
-
end
|
35
|
-
|
36
|
-
if iis_error
|
37
|
-
exit 1
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Publisher
|
2
|
-
class Iis_deploy
|
3
|
-
attr_accessor :iis_deploy_url
|
4
|
-
attr_accessor :iis_deploy_protocol
|
5
|
-
attr_accessor :http_read_timeout
|
6
|
-
|
7
|
-
def deploy(version, iis_application_name, env)
|
8
|
-
Helper.validates_presence_of iis_deploy_url, "IIS URL not set"
|
9
|
-
Helper.validates_presence_of iis_deploy_protocol, "Protocol not set"
|
10
|
-
iis_error = false
|
11
|
-
|
12
|
-
begin
|
13
|
-
uri = URI(iis_deploy_protocol + '://' + iis_deploy_url)
|
14
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
15
|
-
http.read_timeout = http_read_timeout
|
16
|
-
request = Net::HTTP::Post.new uri.request_uri
|
17
|
-
request.set_form_data('version' => version, 'application_name' => iis_application_name, 'env' => env)
|
18
|
-
request.content_type = 'application/x-www-form-urlencoded;charset=utf-8'
|
19
|
-
http.request request do |response|
|
20
|
-
response.read_body do |chunk|
|
21
|
-
if chunk.include?("### Error while executing")
|
22
|
-
$log.writer.error "Error executing deploy on IIS"
|
23
|
-
iis_error = true
|
24
|
-
end
|
25
|
-
$log.writer.info "#{chunk}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
rescue Exception => e
|
30
|
-
$log.writer.error "Error: while connecting to IIS Server"
|
31
|
-
$log.writer.error "Request was: #{uri.to_s}"
|
32
|
-
$log.writer.error e.message
|
33
|
-
exit 1
|
34
|
-
end
|
35
|
-
|
36
|
-
if iis_error
|
37
|
-
exit 1
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Reporter
|
2
|
-
class Mail
|
3
|
-
attr_accessor :deploy_email_from
|
4
|
-
attr_accessor :deploy_email_to
|
5
|
-
attr_accessor :application_name
|
6
|
-
attr_accessor :module_name
|
7
|
-
attr_accessor :environment
|
8
|
-
attr_accessor :version
|
9
|
-
attr_accessor :worker
|
10
|
-
|
11
|
-
def send(options={})
|
12
|
-
Helper.validates_presence_of deploy_email_from, "deploy_email_from not set"
|
13
|
-
Helper.validates_presence_of deploy_email_to, "deploy_email_to not set"
|
14
|
-
Helper.validates_presence_of application_name, "application_name not set"
|
15
|
-
Helper.validates_presence_of module_name, "module_name not set"
|
16
|
-
Helper.validates_presence_of environment, "environment not set"
|
17
|
-
|
18
|
-
status = options[:status] || "done"
|
19
|
-
message = options[:message] || ""
|
20
|
-
|
21
|
-
worker.sendmail(:from => "#{deploy_email_from}", \
|
22
|
-
:to => "#{deploy_email_to}", \
|
23
|
-
:subject => "JENKINS: #{module_name} #{environment} #{application_name} #{status}", \
|
24
|
-
:body => "Module: #{module_name}\nEnvironment: #{environment}\nJob: #{application_name}\nVersion: #{version}\n#{status}.\n\n#{message}" )
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
data/spec/mail_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'log4r'
|
3
|
-
require 'pony'
|
4
|
-
require_relative '../lib/depengine/helper/validations'
|
5
|
-
require_relative '../lib/depengine/helper/mail'
|
6
|
-
require_relative '../lib/depengine/log/log'
|
7
|
-
|
8
|
-
$log = Log::DeploymentLogger.new
|
9
|
-
$log.writer.level = Log4r::ERROR
|
10
|
-
|
11
|
-
describe "mail delivery" do
|
12
|
-
it "should send an email via smtp" do
|
13
|
-
options = {}
|
14
|
-
options[:from] = "#{ENV['USER']}@localhost"
|
15
|
-
options[:to] = "#{ENV['USER']}@localhost"
|
16
|
-
options[:subject] = "spec mail #{Time.now.to_s}"
|
17
|
-
options[:body] = 'test mail'
|
18
|
-
|
19
|
-
worker = Helper::Mail.new
|
20
|
-
worker.smtp_host = 'localhost'
|
21
|
-
worker.sendmail(options)
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|