crazycode-cap-recipes 0.4.0 → 0.4.1
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.
- data/VERSION.yml +1 -1
- data/crazycode-cap-recipes.gemspec +1 -1
- data/lib/cap_recipes/tasks/sdpjenkins.rb +22 -47
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -15,51 +15,16 @@ Capistrano::Configuration.instance(true).load do |configuration|
|
|
15
15
|
_cset :upload_dir, ""
|
16
16
|
_cset :shell_commands, "cd #{upload_dir}; ls -all"
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
if File.exists? deploy_id_file
|
22
|
-
puts "Previous Deploy NOT Complete, please run 'cap cmdb:failback' first."
|
23
|
-
exit(1)
|
24
|
-
end
|
25
|
-
|
26
|
-
deploy_id = CmdbService.start_deploy("#{cse_base}", deploy_unit_code, deploy_stage, tag)
|
27
|
-
|
28
|
-
open(deploy_id_file, 'w') do |f|
|
29
|
-
f.write deploy_id
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "set current deploy FAILBACK!"
|
34
|
-
task :failback do
|
35
|
-
deploy_id = CmdbService.get_deploy_id(deploy_id_file)
|
36
|
-
unless deploy_id.nil?
|
37
|
-
CmdbService.complete_deploy(cse_base, deploy_unit_code, deploy_id, false, "capistrano部署失败,撤销发布")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
desc "set current deploy success DONE!"
|
42
|
-
task :done do
|
43
|
-
deploy_id = CmdbService.get_deploy_id(deploy_id_file)
|
44
|
-
puts "deploy_id=#{deploy_id}, file=#{deploy_id_file}"
|
45
|
-
CmdbService.complete_deploy(cse_base, deploy_unit_code, deploy_id, true, "通过capistrano部署成功")
|
46
|
-
File.delete deploy_id_file
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "deploy to tomcat"
|
50
|
-
task :deploy_to_tomcat do
|
51
|
-
cmdb.start
|
52
|
-
deploy_id = CmdbService.get_deploy_id(deploy_id_file) || CmdbService.start_deploy("#{cse_base}", deploy_unit_code, deploy_stage, tag)
|
53
|
-
puts "deploy_id=#{deploy_id}"
|
18
|
+
# role :app, :primary => true do
|
19
|
+
# CmdbService.get_app_role("#{cse_base}", deploy_unit_code, deploy_stage)
|
20
|
+
# end
|
54
21
|
|
55
|
-
|
56
|
-
tomcat.restart
|
22
|
+
role :single, "1.1.1.1"
|
57
23
|
|
58
|
-
|
59
|
-
end
|
24
|
+
namespace :sdpjenkins do
|
60
25
|
|
61
26
|
desc "copy all war to specify dir"
|
62
|
-
task :copy_to_dir do
|
27
|
+
task :copy_to_dir, :roles => :app do
|
63
28
|
if build_workspace.empty?
|
64
29
|
puts "Please specify the build_workspace dir, set :build_workspace, '/home/foo/project/code'"
|
65
30
|
exit(1)
|
@@ -91,7 +56,7 @@ Capistrano::Configuration.instance(true).load do |configuration|
|
|
91
56
|
end
|
92
57
|
|
93
58
|
desc "upload released file to remote hosts"
|
94
|
-
task :upload_file do
|
59
|
+
task :upload_file, :roles => :app do
|
95
60
|
if upload_dir.empty?
|
96
61
|
puts "Please specify the remote upload_dir, set :upload_dir, '/opt/applications/project/upload'"
|
97
62
|
exit(1)
|
@@ -103,17 +68,27 @@ Capistrano::Configuration.instance(true).load do |configuration|
|
|
103
68
|
end
|
104
69
|
|
105
70
|
desc "execute commands from remote hosts"
|
106
|
-
task :execute_commands do
|
71
|
+
task :execute_commands, :roles => :app do
|
107
72
|
unless shell_commands.empty?
|
108
73
|
run shell_commands
|
109
74
|
end
|
110
75
|
end
|
111
76
|
|
112
77
|
desc "copy file, upload it, then execute commands"
|
113
|
-
task :doall do
|
114
|
-
|
115
|
-
|
116
|
-
|
78
|
+
task :doall, :roles => :single do
|
79
|
+
codes = deploy_unit_code.split(/[,;\s]+/)
|
80
|
+
deploy_hash = Hash.new
|
81
|
+
codes.each {|code| deploy_hash[code] = CmdbService.start_deploy(cse_base, code, deploy_stage, tag) }
|
82
|
+
|
83
|
+
begin
|
84
|
+
copy_to_dir
|
85
|
+
upload_file
|
86
|
+
execute_commands
|
87
|
+
deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, true, "通过capistrano部署成功") }
|
88
|
+
rescue Exception => e
|
89
|
+
deploy_hash.each {|code, deployid| CmdbService.complete_deploy(cse_base, code, deployid, false, "capistrano部署失败,撤销发布,原因:#{e.message}") }
|
90
|
+
end
|
91
|
+
|
117
92
|
end
|
118
93
|
|
119
94
|
end
|