crazycode-cap-recipes 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
+ :major: 0
2
3
  :minor: 4
3
- :patch: 5
4
+ :patch: 6
4
5
  :build:
5
- :major: 0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{crazycode-cap-recipes}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["crazycode"]
12
- s.date = %q{2011-08-23}
12
+ s.date = %q{2011-08-24}
13
13
  s.default_executable = %q{cap-recipes}
14
14
  s.description = %q{Battle-tested capistrano recipes for debian, passenger, apache, hudson, delayed_job, juggernaut, rubygems, backgroundrb, rails and more}
15
15
  s.email = %q{crazycode@gmail.com}
@@ -120,6 +120,15 @@ Gem::Specification.new do |s|
120
120
  s.rubyforge_project = %q{crazycode-cap-recipes}
121
121
  s.rubygems_version = %q{1.3.7}
122
122
  s.summary = %q{Battle-tested capistrano recipes for passenger, delayed_job, and more}
123
+ s.test_files = [
124
+ "examples/advanced/deploy.rb",
125
+ "examples/advanced/deploy/experimental.rb",
126
+ "examples/advanced/deploy/production.rb",
127
+ "examples/simple/deploy.rb",
128
+ "spec/cap/helper.rb",
129
+ "spec/cap_recipes_spec.rb",
130
+ "spec/spec_helper.rb"
131
+ ]
123
132
 
124
133
  if s.respond_to? :specification_version then
125
134
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -26,17 +26,10 @@ Capistrano::Configuration.instance(true).load do |configuration|
26
26
 
27
27
  desc "deploy to tomcat"
28
28
  task :deploy_to_tomcat, :roles => :single do
29
- codes = deploy_unit_code.split(/[,;\s]+/)
30
- deploy_hash = Hash.new
31
- codes.each {|code| deploy_hash[code] = CmdbService.start_deploy(cse_base, code, deploy_stage, build_version) }
32
- begin
29
+ CmdbService.do_deploy(cse_base, deploy_unit_code, deploy_stage, version.strip) do
33
30
  gitdeploy.deploy
34
31
  tomcat.restart
35
- deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, true, "通过capistrano部署成功") }
36
- rescue Exception => e
37
- deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, false, "capistrano部署失败,撤销发布,原因:#{e.message}") }
38
32
  end
39
33
  end
40
-
41
34
  end
42
35
  end
@@ -109,4 +109,16 @@ class CmdbService
109
109
  deploy_id
110
110
  end
111
111
 
112
+ def self.do_deploy(cse_base, unit_code, stage, version)
113
+ codes = unit_code.split(/[,;\s]+/)
114
+ deploy_hash = Hash.new
115
+ codes.each {|code| deploy_hash[code] = CmdbService.start_deploy(cse_base, code, stage, version) }
116
+
117
+ begin
118
+ yield
119
+ deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, true, "通过capistrano部署成功") }
120
+ rescue Exception => e
121
+ deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, false, "capistrano部署失败,撤销发布,原因:#{e.message}") }
122
+ end
123
+ end
112
124
  end
@@ -22,9 +22,9 @@ Capistrano::Configuration.instance(true).load do |configuration|
22
22
  _cset :shell_commands, "cd #{upload_dir}; ls -all"
23
23
  _cset :build_version, "unset version"
24
24
 
25
- # role :app, :primary => true do
26
- # CmdbService.get_app_role("#{cse_base}", deploy_unit_code, deploy_stage)
27
- # end
25
+ role :app, :primary => true do
26
+ CmdbService.get_app_role("#{cse_base}", deploy_unit_code, deploy_stage)
27
+ end
28
28
 
29
29
  role :single, "1.1.1.1"
30
30
 
@@ -60,7 +60,7 @@ Capistrano::Configuration.instance(true).load do |configuration|
60
60
  cp file, "#{release_dir}/#{target_name}"
61
61
  end
62
62
 
63
- system "echo \"#{build_version}\" > #{release_dir}/version.txt"
63
+ system "echo \"#{build_version}\" >> #{release_dir}/version.txt"
64
64
 
65
65
  end
66
66
 
@@ -85,18 +85,16 @@ Capistrano::Configuration.instance(true).load do |configuration|
85
85
 
86
86
  desc "upload release file, then execute commands"
87
87
  task :deploy, :roles => :single do
88
- codes = deploy_unit_code.split(/[,;\s]+/)
89
- deploy_hash = Hash.new
90
- codes.each {|code| deploy_hash[code] = CmdbService.start_deploy(cse_base, code, deploy_stage, tag) }
88
+ version = build_version
89
+ if version.empty? && File.exists?("#{release_dir}/version.txt")
90
+ version = File.open("#{release_dir}/version.txt") { |f| f.extend(Enumerable).inject { |_,ln| ln } }
91
+ end
92
+ puts "version=#{version}"
91
93
 
92
- begin
94
+ CmdbService.do_deploy(cse_base, deploy_unit_code, deploy_stage, version.strip) do
93
95
  upload_file
94
96
  execute_commands
95
- deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, true, "通过capistrano部署成功") }
96
- rescue Exception => e
97
- deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, false, "capistrano部署失败,撤销发布,原因:#{e.message}") }
98
97
  end
99
-
100
98
  end
101
99
 
102
100
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crazycode-cap-recipes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 5
10
- version: 0.4.5
8
+ - 6
9
+ version: 0.4.6
11
10
  platform: ruby
12
11
  authors:
13
12
  - crazycode
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-08-23 00:00:00 +08:00
17
+ date: 2011-08-24 00:00:00 +08:00
19
18
  default_executable: cap-recipes
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
@@ -40,7 +38,6 @@ dependencies:
40
38
  requirements:
41
39
  - - ">="
42
40
  - !ruby/object:Gem::Version
43
- hash: 3
44
41
  segments:
45
42
  - 0
46
43
  version: "0"
@@ -54,7 +51,6 @@ dependencies:
54
51
  requirements:
55
52
  - - ">="
56
53
  - !ruby/object:Gem::Version
57
- hash: 3
58
54
  segments:
59
55
  - 0
60
56
  version: "0"
@@ -179,7 +175,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
175
  requirements:
180
176
  - - ">="
181
177
  - !ruby/object:Gem::Version
182
- hash: 3
183
178
  segments:
184
179
  - 0
185
180
  version: "0"
@@ -188,7 +183,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
183
  requirements:
189
184
  - - ">="
190
185
  - !ruby/object:Gem::Version
191
- hash: 3
192
186
  segments:
193
187
  - 0
194
188
  version: "0"
@@ -199,5 +193,11 @@ rubygems_version: 1.3.7
199
193
  signing_key:
200
194
  specification_version: 3
201
195
  summary: Battle-tested capistrano recipes for passenger, delayed_job, and more
202
- test_files: []
203
-
196
+ test_files:
197
+ - examples/advanced/deploy.rb
198
+ - examples/advanced/deploy/experimental.rb
199
+ - examples/advanced/deploy/production.rb
200
+ - examples/simple/deploy.rb
201
+ - spec/cap/helper.rb
202
+ - spec/cap_recipes_spec.rb
203
+ - spec/spec_helper.rb