capistrano 3.4.1 → 3.5.0
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/.gitignore +7 -5
- data/.rubocop.yml +49 -0
- data/.travis.yml +5 -4
- data/CHANGELOG.md +72 -9
- data/CONTRIBUTING.md +61 -93
- data/DEVELOPMENT.md +122 -0
- data/Gemfile +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +121 -43
- data/RELEASING.md +16 -0
- data/Rakefile +4 -1
- data/bin/cap +1 -1
- data/capistrano.gemspec +16 -21
- data/features/doctor.feature +11 -0
- data/features/step_definitions/assertions.rb +17 -17
- data/features/step_definitions/cap_commands.rb +0 -1
- data/features/step_definitions/setup.rb +12 -8
- data/features/support/env.rb +5 -5
- data/features/support/remote_command_helpers.rb +8 -6
- data/features/support/vagrant_helpers.rb +5 -4
- data/issue_template.md +21 -0
- data/lib/Capfile +5 -1
- data/lib/capistrano/all.rb +9 -10
- data/lib/capistrano/application.rb +36 -26
- data/lib/capistrano/configuration.rb +56 -41
- data/lib/capistrano/configuration/empty_filter.rb +9 -0
- data/lib/capistrano/configuration/filter.rb +18 -47
- data/lib/capistrano/configuration/host_filter.rb +30 -0
- data/lib/capistrano/configuration/null_filter.rb +9 -0
- data/lib/capistrano/configuration/plugin_installer.rb +33 -0
- data/lib/capistrano/configuration/question.rb +10 -7
- data/lib/capistrano/configuration/role_filter.rb +30 -0
- data/lib/capistrano/configuration/server.rb +22 -23
- data/lib/capistrano/configuration/servers.rb +6 -7
- data/lib/capistrano/configuration/variables.rb +136 -0
- data/lib/capistrano/defaults.rb +13 -3
- data/lib/capistrano/deploy.rb +1 -1
- data/lib/capistrano/doctor.rb +5 -0
- data/lib/capistrano/doctor/environment_doctor.rb +19 -0
- data/lib/capistrano/doctor/gems_doctor.rb +45 -0
- data/lib/capistrano/doctor/output_helpers.rb +79 -0
- data/lib/capistrano/doctor/variables_doctor.rb +66 -0
- data/lib/capistrano/dotfile.rb +1 -2
- data/lib/capistrano/dsl.rb +12 -14
- data/lib/capistrano/dsl/env.rb +11 -42
- data/lib/capistrano/dsl/paths.rb +12 -13
- data/lib/capistrano/dsl/stages.rb +2 -4
- data/lib/capistrano/dsl/task_enhancements.rb +5 -7
- data/lib/capistrano/framework.rb +1 -1
- data/lib/capistrano/git.rb +17 -9
- data/lib/capistrano/hg.rb +4 -4
- data/lib/capistrano/i18n.rb +24 -24
- data/lib/capistrano/immutable_task.rb +29 -0
- data/lib/capistrano/install.rb +1 -1
- data/lib/capistrano/plugin.rb +95 -0
- data/lib/capistrano/scm.rb +7 -20
- data/lib/capistrano/setup.rb +19 -5
- data/lib/capistrano/svn.rb +9 -5
- data/lib/capistrano/tasks/console.rake +4 -8
- data/lib/capistrano/tasks/deploy.rake +75 -62
- data/lib/capistrano/tasks/doctor.rake +19 -0
- data/lib/capistrano/tasks/framework.rake +13 -14
- data/lib/capistrano/tasks/git.rake +10 -11
- data/lib/capistrano/tasks/hg.rake +7 -7
- data/lib/capistrano/tasks/install.rake +14 -15
- data/lib/capistrano/tasks/svn.rake +7 -7
- data/lib/capistrano/templates/Capfile +3 -3
- data/lib/capistrano/templates/deploy.rb.erb +6 -5
- data/lib/capistrano/upload_task.rb +1 -1
- data/lib/capistrano/version.rb +1 -1
- data/lib/capistrano/version_validator.rb +4 -6
- data/spec/integration/dsl_spec.rb +286 -239
- data/spec/integration_spec_helper.rb +3 -5
- data/spec/lib/capistrano/application_spec.rb +22 -14
- data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/filter_spec.rb +82 -84
- data/spec/lib/capistrano/configuration/host_filter_spec.rb +61 -0
- data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/question_spec.rb +12 -16
- data/spec/lib/capistrano/configuration/role_filter_spec.rb +64 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +102 -110
- data/spec/lib/capistrano/configuration/servers_spec.rb +124 -141
- data/spec/lib/capistrano/configuration_spec.rb +150 -61
- data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
- data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +61 -0
- data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
- data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +79 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +58 -50
- data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +62 -32
- data/spec/lib/capistrano/dsl_spec.rb +6 -8
- data/spec/lib/capistrano/git_spec.rb +35 -7
- data/spec/lib/capistrano/hg_spec.rb +14 -5
- data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
- data/spec/lib/capistrano/plugin_spec.rb +84 -0
- data/spec/lib/capistrano/scm_spec.rb +6 -7
- data/spec/lib/capistrano/svn_spec.rb +40 -14
- data/spec/lib/capistrano/upload_task_spec.rb +7 -7
- data/spec/lib/capistrano/version_validator_spec.rb +37 -45
- data/spec/lib/capistrano_spec.rb +2 -3
- data/spec/spec_helper.rb +8 -8
- data/spec/support/Vagrantfile +9 -10
- data/spec/support/tasks/database.rake +3 -3
- data/spec/support/tasks/fail.rake +4 -3
- data/spec/support/tasks/failed.rake +2 -2
- data/spec/support/tasks/plugin.rake +6 -0
- data/spec/support/tasks/root.rake +4 -4
- data/spec/support/test_app.rb +31 -30
- metadata +93 -14
data/lib/capistrano/svn.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
load File.expand_path("../tasks/svn.rake", __FILE__)
|
2
2
|
|
3
|
-
require
|
3
|
+
require "capistrano/scm"
|
4
4
|
|
5
5
|
class Capistrano::Svn < Capistrano::SCM
|
6
|
-
|
7
6
|
# execute svn in context with arguments
|
8
7
|
def svn(*args)
|
9
8
|
args.unshift(:svn)
|
10
|
-
|
9
|
+
args.push "--username #{fetch(:svn_username)}" if fetch(:svn_username)
|
10
|
+
args.push "--password #{fetch(:svn_password)}" if fetch(:svn_password)
|
11
|
+
args.push "--revision #{fetch(:svn_revision)}" if fetch(:svn_revision)
|
12
|
+
context.execute(*args)
|
11
13
|
end
|
12
14
|
|
13
15
|
module DefaultStrategy
|
@@ -16,7 +18,9 @@ class Capistrano::Svn < Capistrano::SCM
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def check
|
19
|
-
|
21
|
+
svn_username = fetch(:svn_username) ? "--username #{fetch(:svn_username)}" : ""
|
22
|
+
svn_password = fetch(:svn_password) ? "--password #{fetch(:svn_password)}" : ""
|
23
|
+
test! :svn, :info, repo_url, svn_username, svn_password
|
20
24
|
end
|
21
25
|
|
22
26
|
def clone
|
@@ -28,7 +32,7 @@ class Capistrano::Svn < Capistrano::SCM
|
|
28
32
|
end
|
29
33
|
|
30
34
|
def release
|
31
|
-
svn :export,
|
35
|
+
svn :export, "--force", ".", release_path
|
32
36
|
end
|
33
37
|
|
34
38
|
def fetch_revision
|
@@ -1,20 +1,16 @@
|
|
1
|
-
desc
|
1
|
+
desc "Execute remote commands"
|
2
2
|
task :console do
|
3
3
|
stage = fetch(:stage)
|
4
|
-
puts I18n.t(
|
4
|
+
puts I18n.t("console.welcome", scope: :capistrano, stage: stage)
|
5
5
|
loop do
|
6
6
|
print "#{stage}> "
|
7
7
|
|
8
|
-
|
9
|
-
command = input.chomp
|
10
|
-
else
|
11
|
-
command = 'exit'
|
12
|
-
end
|
8
|
+
command = (input = $stdin.gets) ? input.chomp : "exit"
|
13
9
|
|
14
10
|
next if command.empty?
|
15
11
|
|
16
12
|
if %w{quit exit q}.include? command
|
17
|
-
puts t(
|
13
|
+
puts t("console.bye")
|
18
14
|
break
|
19
15
|
else
|
20
16
|
begin
|
@@ -1,70 +1,90 @@
|
|
1
1
|
namespace :deploy do
|
2
|
-
|
3
2
|
task :starting do
|
4
|
-
invoke
|
5
|
-
invoke
|
3
|
+
invoke "deploy:print_config_variables" if fetch(:print_config_variables, false)
|
4
|
+
invoke "deploy:check"
|
5
|
+
invoke "deploy:set_previous_revision"
|
6
|
+
end
|
7
|
+
|
8
|
+
task :print_config_variables do
|
9
|
+
puts
|
10
|
+
puts "------- Printing current config variables -------"
|
11
|
+
env.keys.each do |config_variable_key|
|
12
|
+
if is_question?(config_variable_key)
|
13
|
+
puts "#{config_variable_key.inspect} => Question (awaits user input on next fetch(#{config_variable_key.inspect}))"
|
14
|
+
else
|
15
|
+
puts "#{config_variable_key.inspect} => #{fetch(config_variable_key).inspect}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
puts
|
20
|
+
puts "------- Printing current config variables of SSHKit mechanism -------"
|
21
|
+
puts env.backend.config.inspect
|
22
|
+
# puts env.backend.config.backend.config.ssh_options.inspect
|
23
|
+
# puts env.backend.config.command_map.defaults.inspect
|
24
|
+
|
25
|
+
puts
|
6
26
|
end
|
7
27
|
|
8
|
-
task :
|
28
|
+
task updating: :new_release_path do
|
9
29
|
invoke "#{scm}:create_release"
|
10
30
|
invoke "deploy:set_current_revision"
|
11
|
-
invoke
|
31
|
+
invoke "deploy:symlink:shared"
|
12
32
|
end
|
13
33
|
|
14
34
|
task :reverting do
|
15
|
-
invoke
|
35
|
+
invoke "deploy:revert_release"
|
16
36
|
end
|
17
37
|
|
18
38
|
task :publishing do
|
19
|
-
invoke
|
39
|
+
invoke "deploy:symlink:release"
|
20
40
|
end
|
21
41
|
|
22
42
|
task :finishing do
|
23
|
-
invoke
|
43
|
+
invoke "deploy:cleanup"
|
24
44
|
end
|
25
45
|
|
26
46
|
task :finishing_rollback do
|
27
|
-
invoke
|
47
|
+
invoke "deploy:cleanup_rollback"
|
28
48
|
end
|
29
49
|
|
30
50
|
task :finished do
|
31
|
-
invoke
|
51
|
+
invoke "deploy:log_revision"
|
32
52
|
end
|
33
53
|
|
34
|
-
desc
|
54
|
+
desc "Check required files and directories exist"
|
35
55
|
task :check do
|
36
56
|
invoke "#{scm}:check"
|
37
|
-
invoke
|
38
|
-
invoke
|
39
|
-
invoke
|
40
|
-
invoke
|
57
|
+
invoke "deploy:check:directories"
|
58
|
+
invoke "deploy:check:linked_dirs"
|
59
|
+
invoke "deploy:check:make_linked_dirs"
|
60
|
+
invoke "deploy:check:linked_files"
|
41
61
|
end
|
42
62
|
|
43
63
|
namespace :check do
|
44
|
-
desc
|
64
|
+
desc "Check shared and release directories exist"
|
45
65
|
task :directories do
|
46
66
|
on release_roles :all do
|
47
|
-
execute :mkdir,
|
67
|
+
execute :mkdir, "-p", shared_path, releases_path
|
48
68
|
end
|
49
69
|
end
|
50
70
|
|
51
|
-
desc
|
71
|
+
desc "Check directories to be linked exist in shared"
|
52
72
|
task :linked_dirs do
|
53
73
|
next unless any? :linked_dirs
|
54
74
|
on release_roles :all do
|
55
|
-
execute :mkdir,
|
75
|
+
execute :mkdir, "-p", linked_dirs(shared_path)
|
56
76
|
end
|
57
77
|
end
|
58
78
|
|
59
|
-
desc
|
79
|
+
desc "Check directories of files to be linked exist in shared"
|
60
80
|
task :make_linked_dirs do
|
61
81
|
next unless any? :linked_files
|
62
|
-
on release_roles :all do |
|
63
|
-
execute :mkdir,
|
82
|
+
on release_roles :all do |_host|
|
83
|
+
execute :mkdir, "-p", linked_file_dirs(shared_path)
|
64
84
|
end
|
65
85
|
end
|
66
86
|
|
67
|
-
desc
|
87
|
+
desc "Check files to be linked exist in shared"
|
68
88
|
task :linked_files do
|
69
89
|
next unless any? :linked_files
|
70
90
|
on release_roles :all do |host|
|
@@ -79,64 +99,58 @@ namespace :deploy do
|
|
79
99
|
end
|
80
100
|
|
81
101
|
namespace :symlink do
|
82
|
-
desc
|
102
|
+
desc "Symlink release to current"
|
83
103
|
task :release do
|
84
104
|
on release_roles :all do
|
85
105
|
tmp_current_path = release_path.parent.join(current_path.basename)
|
86
|
-
execute :ln,
|
106
|
+
execute :ln, "-s", release_path, tmp_current_path
|
87
107
|
execute :mv, tmp_current_path, current_path.parent
|
88
108
|
end
|
89
109
|
end
|
90
110
|
|
91
|
-
desc
|
111
|
+
desc "Symlink files and directories from shared to release"
|
92
112
|
task :shared do
|
93
|
-
invoke
|
94
|
-
invoke
|
113
|
+
invoke "deploy:symlink:linked_files"
|
114
|
+
invoke "deploy:symlink:linked_dirs"
|
95
115
|
end
|
96
116
|
|
97
|
-
desc
|
117
|
+
desc "Symlink linked directories"
|
98
118
|
task :linked_dirs do
|
99
119
|
next unless any? :linked_dirs
|
100
120
|
on release_roles :all do
|
101
|
-
execute :mkdir,
|
121
|
+
execute :mkdir, "-p", linked_dir_parents(release_path)
|
102
122
|
|
103
123
|
fetch(:linked_dirs).each do |dir|
|
104
124
|
target = release_path.join(dir)
|
105
125
|
source = shared_path.join(dir)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
110
|
-
execute :ln, '-s', source, target
|
111
|
-
end
|
126
|
+
next if test "[ -L #{target} ]"
|
127
|
+
execute :rm, "-rf", target if test "[ -d #{target} ]"
|
128
|
+
execute :ln, "-s", source, target
|
112
129
|
end
|
113
130
|
end
|
114
131
|
end
|
115
132
|
|
116
|
-
desc
|
133
|
+
desc "Symlink linked files"
|
117
134
|
task :linked_files do
|
118
135
|
next unless any? :linked_files
|
119
136
|
on release_roles :all do
|
120
|
-
execute :mkdir,
|
137
|
+
execute :mkdir, "-p", linked_file_dirs(release_path)
|
121
138
|
|
122
139
|
fetch(:linked_files).each do |file|
|
123
140
|
target = release_path.join(file)
|
124
141
|
source = shared_path.join(file)
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
execute :ln, '-s', source, target
|
130
|
-
end
|
142
|
+
next if test "[ -L #{target} ]"
|
143
|
+
execute :rm, target if test "[ -f #{target} ]"
|
144
|
+
execute :ln, "-s", source, target
|
131
145
|
end
|
132
146
|
end
|
133
147
|
end
|
134
148
|
end
|
135
149
|
|
136
|
-
desc
|
150
|
+
desc "Clean up old releases"
|
137
151
|
task :cleanup do
|
138
152
|
on release_roles :all do |host|
|
139
|
-
releases = capture(:ls,
|
153
|
+
releases = capture(:ls, "-xtr", releases_path).split
|
140
154
|
if releases.count >= fetch(:keep_releases)
|
141
155
|
info t(:keeping_releases, host: host.to_s, keep_releases: fetch(:keep_releases), releases: releases.count)
|
142
156
|
directories = (releases - releases.last(fetch(:keep_releases)))
|
@@ -144,7 +158,7 @@ namespace :deploy do
|
|
144
158
|
directories_str = directories.map do |release|
|
145
159
|
releases_path.join(release)
|
146
160
|
end.join(" ")
|
147
|
-
execute :rm,
|
161
|
+
execute :rm, "-rf", directories_str
|
148
162
|
else
|
149
163
|
info t(:no_old_releases, host: host.to_s, keep_releases: fetch(:keep_releases))
|
150
164
|
end
|
@@ -152,33 +166,33 @@ namespace :deploy do
|
|
152
166
|
end
|
153
167
|
end
|
154
168
|
|
155
|
-
desc
|
169
|
+
desc "Remove and archive rolled-back release."
|
156
170
|
task :cleanup_rollback do
|
157
171
|
on release_roles(:all) do
|
158
|
-
last_release = capture(:ls,
|
172
|
+
last_release = capture(:ls, "-xt", releases_path).split.first
|
159
173
|
last_release_path = releases_path.join(last_release)
|
160
174
|
if test "[ `readlink #{current_path}` != #{last_release_path} ]"
|
161
|
-
execute :tar,
|
162
|
-
|
163
|
-
|
164
|
-
execute :rm,
|
175
|
+
execute :tar, "-czf",
|
176
|
+
deploy_path.join("rolled-back-release-#{last_release}.tar.gz"),
|
177
|
+
last_release_path
|
178
|
+
execute :rm, "-rf", last_release_path
|
165
179
|
else
|
166
|
-
debug
|
180
|
+
debug "Last release is the current release, skip cleanup_rollback."
|
167
181
|
end
|
168
182
|
end
|
169
183
|
end
|
170
184
|
|
171
|
-
desc
|
185
|
+
desc "Log details of the deploy"
|
172
186
|
task :log_revision do
|
173
187
|
on release_roles(:all) do
|
174
188
|
within releases_path do
|
175
|
-
execute %{
|
189
|
+
execute :echo, %Q{"#{revision_log_message}" >> #{revision_log}}
|
176
190
|
end
|
177
191
|
end
|
178
192
|
end
|
179
193
|
|
180
|
-
desc
|
181
|
-
task :
|
194
|
+
desc "Revert to previous release timestamp"
|
195
|
+
task revert_release: :rollback_release_path do
|
182
196
|
on release_roles(:all) do
|
183
197
|
set(:revision_log_message, rollback_log_message)
|
184
198
|
end
|
@@ -190,7 +204,7 @@ namespace :deploy do
|
|
190
204
|
|
191
205
|
task :rollback_release_path do
|
192
206
|
on release_roles(:all) do
|
193
|
-
releases = capture(:ls,
|
207
|
+
releases = capture(:ls, "-xt", releases_path).split
|
194
208
|
if releases.count < 2
|
195
209
|
error t(:cannot_rollback)
|
196
210
|
exit 1
|
@@ -213,14 +227,13 @@ namespace :deploy do
|
|
213
227
|
|
214
228
|
task :set_previous_revision do
|
215
229
|
on release_roles(:all) do
|
216
|
-
target = release_path.join(
|
230
|
+
target = release_path.join("REVISION")
|
217
231
|
if test "[ -f #{target} ]"
|
218
|
-
set(:previous_revision, capture(:cat, target,
|
232
|
+
set(:previous_revision, capture(:cat, target, "2>/dev/null"))
|
219
233
|
end
|
220
234
|
end
|
221
235
|
end
|
222
236
|
|
223
237
|
task :restart
|
224
238
|
task :failed
|
225
|
-
|
226
239
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
desc "Display a Capistrano troubleshooting report (all doctor: tasks)"
|
2
|
+
task doctor: ["doctor:environment", "doctor:gems", "doctor:variables"]
|
3
|
+
|
4
|
+
namespace :doctor do
|
5
|
+
desc "Display Ruby environment details"
|
6
|
+
task :environment do
|
7
|
+
Capistrano::Doctor::EnvironmentDoctor.new.call
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Display Capistrano gem versions"
|
11
|
+
task :gems do
|
12
|
+
Capistrano::Doctor::GemsDoctor.new.call
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Display the values of all Capistrano variables"
|
16
|
+
task :variables do
|
17
|
+
Capistrano::Doctor::VariablesDoctor.new.call
|
18
|
+
end
|
19
|
+
end
|
@@ -1,50 +1,49 @@
|
|
1
1
|
namespace :deploy do
|
2
|
-
|
3
|
-
desc 'Start a deployment, make sure server(s) ready.'
|
2
|
+
desc "Start a deployment, make sure server(s) ready."
|
4
3
|
task :starting do
|
5
4
|
end
|
6
5
|
|
7
|
-
desc
|
6
|
+
desc "Started"
|
8
7
|
task :started do
|
9
8
|
end
|
10
9
|
|
11
|
-
desc
|
10
|
+
desc "Update server(s) by setting up a new release."
|
12
11
|
task :updating do
|
13
12
|
end
|
14
13
|
|
15
|
-
desc
|
14
|
+
desc "Updated"
|
16
15
|
task :updated do
|
17
16
|
end
|
18
17
|
|
19
|
-
desc
|
18
|
+
desc "Revert server(s) to previous release."
|
20
19
|
task :reverting do
|
21
20
|
end
|
22
21
|
|
23
|
-
desc
|
22
|
+
desc "Reverted"
|
24
23
|
task :reverted do
|
25
24
|
end
|
26
25
|
|
27
|
-
desc
|
26
|
+
desc "Publish the release."
|
28
27
|
task :publishing do
|
29
28
|
end
|
30
29
|
|
31
|
-
desc
|
30
|
+
desc "Published"
|
32
31
|
task :published do
|
33
32
|
end
|
34
33
|
|
35
|
-
desc
|
34
|
+
desc "Finish the deployment, clean up server(s)."
|
36
35
|
task :finishing do
|
37
36
|
end
|
38
37
|
|
39
|
-
desc
|
38
|
+
desc "Finish the rollback, clean up server(s)."
|
40
39
|
task :finishing_rollback do
|
41
40
|
end
|
42
41
|
|
43
|
-
desc
|
42
|
+
desc "Finished"
|
44
43
|
task :finished do
|
45
44
|
end
|
46
45
|
|
47
|
-
desc
|
46
|
+
desc "Rollback to previous release."
|
48
47
|
task :rollback do
|
49
48
|
%w{ starting started
|
50
49
|
reverting reverted
|
@@ -55,7 +54,7 @@ namespace :deploy do
|
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
|
-
desc
|
57
|
+
desc "Deploy a new release."
|
59
58
|
task :deploy do
|
60
59
|
set(:deploying, true)
|
61
60
|
%w{ starting started
|
@@ -1,26 +1,25 @@
|
|
1
1
|
namespace :git do
|
2
|
-
|
3
2
|
def strategy
|
4
3
|
@strategy ||= Capistrano::Git.new(self, fetch(:git_strategy, Capistrano::Git::DefaultStrategy))
|
5
4
|
end
|
6
5
|
|
7
|
-
set :git_environmental_variables,
|
6
|
+
set :git_environmental_variables, lambda {
|
8
7
|
{
|
9
8
|
git_askpass: "/bin/echo",
|
10
|
-
git_ssh:
|
9
|
+
git_ssh: "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
|
11
10
|
}
|
12
11
|
}
|
13
12
|
|
14
|
-
desc
|
13
|
+
desc "Upload the git wrapper script, this script guarantees that we can script git without getting an interactive prompt"
|
15
14
|
task :wrapper do
|
16
15
|
on release_roles :all do
|
17
16
|
execute :mkdir, "-p", "#{fetch(:tmp_dir)}/#{fetch(:application)}/"
|
18
17
|
upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
|
19
|
-
execute :chmod, "+
|
18
|
+
execute :chmod, "+rx", "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
desc
|
22
|
+
desc "Check that the repository is reachable"
|
24
23
|
task check: :'git:wrapper' do
|
25
24
|
fetch(:branch)
|
26
25
|
on release_roles :all do
|
@@ -30,7 +29,7 @@ namespace :git do
|
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
|
-
desc
|
32
|
+
desc "Clone the repo to the cache"
|
34
33
|
task clone: :'git:wrapper' do
|
35
34
|
on release_roles :all do
|
36
35
|
if strategy.test
|
@@ -45,7 +44,7 @@ namespace :git do
|
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
|
-
desc
|
47
|
+
desc "Update the repo mirror to reflect the origin state"
|
49
48
|
task update: :'git:clone' do
|
50
49
|
on release_roles :all do
|
51
50
|
within repo_path do
|
@@ -56,19 +55,19 @@ namespace :git do
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
desc
|
58
|
+
desc "Copy repo to releases"
|
60
59
|
task create_release: :'git:update' do
|
61
60
|
on release_roles :all do
|
62
61
|
with fetch(:git_environmental_variables) do
|
63
62
|
within repo_path do
|
64
|
-
execute :mkdir,
|
63
|
+
execute :mkdir, "-p", release_path
|
65
64
|
strategy.release
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
71
|
-
desc
|
70
|
+
desc "Determine the revision that will be deployed"
|
72
71
|
task :set_current_revision do
|
73
72
|
on release_roles :all do
|
74
73
|
within repo_path do
|