capistrano-psw 1.0.0.pre38 → 1.0.0.pre39
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61844376dd74db07e8d369866efce6a3baec4860
|
4
|
+
data.tar.gz: 24cbc7d057ceb1de58284ad4ab6a82208198de45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f99b1ee1b09f685e7b1799b52c91dd1f9ea848aa59314506e642caafcbc6affb2f6404d4624575d6106967555ff2cc5edd68da6be7c7575a15f321f3d193226
|
7
|
+
data.tar.gz: 29690b4288ded75556ee8bf4ceb3687a84fe09718d426bffc68193d6943f772541fae28eb157bbf364199437809efd4b727a4d10f36e6e85995061e99a376d13
|
data/README.md
CHANGED
@@ -246,6 +246,10 @@ This task will update Capistrano branch environment to point to the Peppr branch
|
|
246
246
|
This task will create a symbolic link from the remote artifacts directory to the current
|
247
247
|
release directory as "/artifacts"
|
248
248
|
|
249
|
+
### psw_peppr_app_deploy:cleanup_old_deployments
|
250
|
+
This task (hooked after deploy:cleanup) will delete any old deployment directories on
|
251
|
+
the Peppr build slave as well as the remote host machine
|
252
|
+
|
249
253
|
```ruby
|
250
254
|
#set psw app deploy prefs
|
251
255
|
before 'psw_peppr_app_deploy:default', :set_app_deploy_options do
|
@@ -18,6 +18,9 @@ module PepprAppDeployFileUtils
|
|
18
18
|
PEPPR_RELATIVE_SHARED_FILE_DIR = "/shared_files"
|
19
19
|
PEPPR_RELATIVE_ARTIFACTS_DIR = "/artifacts"
|
20
20
|
|
21
|
+
# Method to determine if Peppr is executing this deployment
|
22
|
+
#
|
23
|
+
# @return [Boolean] true if Peppr executed Capistrano
|
21
24
|
def self.peppr_deployment?
|
22
25
|
application_id = ENV['peppr_application_id'].to_i
|
23
26
|
application_deployment = ENV['peppr_application_deployment_id'].to_i
|
@@ -25,8 +28,25 @@ module PepprAppDeployFileUtils
|
|
25
28
|
|
26
29
|
false
|
27
30
|
end
|
31
|
+
|
32
|
+
# Method to retrieve the current application identifier (if the deployment
|
33
|
+
# was executed from Peppr)
|
34
|
+
#
|
35
|
+
# @return [Integer] if Peppr executed Capistrano (null otherwise)
|
36
|
+
def self.get_application_id
|
37
|
+
ENV['peppr_application_id'].to_i
|
38
|
+
end
|
39
|
+
|
40
|
+
# Method to retrieve the current deployment number (if the deployment
|
41
|
+
# was executed from Peppr)
|
42
|
+
#
|
43
|
+
# @return [Integer] if Peppr executed Capistrano (null otherwise)
|
44
|
+
def self.get_deployment_number
|
45
|
+
ENV['peppr_application_deployment_id'].to_i
|
46
|
+
end
|
28
47
|
|
29
48
|
module Local
|
49
|
+
|
30
50
|
# Method for verifying that Peppr's application deployment file structure exists on the
|
31
51
|
# local machine.
|
32
52
|
#
|
@@ -45,16 +65,24 @@ module PepprAppDeployFileUtils
|
|
45
65
|
end
|
46
66
|
end
|
47
67
|
|
68
|
+
# Method to build the deployment directory path for a specific deployment
|
69
|
+
#
|
70
|
+
# @param [String] application_id - application identifier
|
71
|
+
# @return [String] deployment_number - deployment number
|
72
|
+
def self.build_deployment_dir(application_id, deployment_number)
|
73
|
+
"/tmp/peppr_deployments/applications/#{application_id}/deployments/#{deployment_number}"
|
74
|
+
end
|
75
|
+
|
48
76
|
# Method for retrieving the base or relative Peppr application deployment directory
|
49
77
|
#
|
50
78
|
# @param [String] relative_dir - relative deployment sub-directory
|
51
79
|
# @return [String] the fully-qualified local directory
|
52
80
|
def self.get_deployment_dir(relative_dir="")
|
53
|
-
application_id =
|
54
|
-
|
81
|
+
application_id = PepprAppDeployFileUtils::get_application_id
|
82
|
+
deployment_number = PepprAppDeployFileUtils::get_deployment_number
|
55
83
|
|
56
|
-
raise ArgumentError.new("peppr_application_id and peppr_application_deployment_id must be defined as part of the Capistrano deployment!") unless application_id > 0 &&
|
57
|
-
"
|
84
|
+
raise ArgumentError.new("peppr_application_id and peppr_application_deployment_id must be defined as part of the Capistrano deployment!") unless application_id > 0 && deployment_number > 0
|
85
|
+
"#{PepprAppDeployFileUtils::Local::build_deployment_dir(application_id, deployment_number)}#{relative_dir}"
|
58
86
|
end
|
59
87
|
|
60
88
|
# Method for retrieving the Peppr application deployment source directory
|
@@ -134,16 +162,24 @@ module PepprAppDeployFileUtils
|
|
134
162
|
end
|
135
163
|
end
|
136
164
|
|
165
|
+
# Method to build the deployment directory path for a specific deployment
|
166
|
+
#
|
167
|
+
# @param [String] application_id - application identifier
|
168
|
+
# @return [String] deployment_number - deployment number
|
169
|
+
def self.build_deployment_dir(application_id, deployment_number)
|
170
|
+
"/tmp/peppr_deployments_remote/applications/#{application_id}/deployments/#{deployment_number}"
|
171
|
+
end
|
172
|
+
|
137
173
|
# Method for retrieving the base or relative Peppr application deployment directory
|
138
174
|
#
|
139
175
|
# @param [String] relative_dir - relative deployment sub-directory
|
140
176
|
# @return [String] the fully-qualified local directory
|
141
177
|
def self.get_deployment_dir(relative_dir="")
|
142
|
-
application_id =
|
143
|
-
|
178
|
+
application_id = PepprAppDeployFileUtils::get_application_id
|
179
|
+
deployment_number = PepprAppDeployFileUtils::get_deployment_number
|
144
180
|
|
145
|
-
raise ArgumentError.new("peppr_application_id and peppr_application_deployment_id must be defined as part of the Capistrano deployment!") unless application_id > 0 &&
|
146
|
-
"
|
181
|
+
raise ArgumentError.new("peppr_application_id and peppr_application_deployment_id must be defined as part of the Capistrano deployment!") unless application_id > 0 && deployment_number > 0
|
182
|
+
"#{PepprAppDeployFileUtils::Remote::build_deployment_dir(application_id, deployment_number)}#{relative_dir}"
|
147
183
|
end
|
148
184
|
|
149
185
|
# Method for retrieving the Peppr application deployment source directory
|
@@ -40,6 +40,14 @@
|
|
40
40
|
# This task will create a symbolic link from the remote artifacts directory to the current
|
41
41
|
# release directory as "/artifacts"
|
42
42
|
#
|
43
|
+
# === psw_peppr_app_deploy:symlink_env_files
|
44
|
+
# This task (hooked after deploy:check:directories) will create symlinks for any environment
|
45
|
+
# files to Capistrano's shared directory
|
46
|
+
#
|
47
|
+
# === psw_peppr_app_deploy:cleanup_old_deployments
|
48
|
+
# This task (hooked after deploy:cleanup) will delete any old deployment directories on
|
49
|
+
# the Peppr build slave as well as the remote host machine
|
50
|
+
#
|
43
51
|
# == Contact
|
44
52
|
#
|
45
53
|
# Author:: Lexmark International Technology S.A.
|
@@ -47,6 +55,8 @@
|
|
47
55
|
# License:: 3-Clause BSD
|
48
56
|
require 'capistrano/psw/peppr_app_deploy_file_utils'
|
49
57
|
require 'capistrano/dsl'
|
58
|
+
|
59
|
+
#required for task 'deploy:check:directories' and task 'deploy:cleanup'
|
50
60
|
require 'capistrano/deploy'
|
51
61
|
|
52
62
|
namespace :psw_peppr_app_deploy do
|
@@ -235,4 +245,32 @@ namespace :psw_peppr_app_deploy do
|
|
235
245
|
#(https://github.com/capistrano/capistrano/blob/6353a02ed63dfe7f16921650e3b6e6d6317f0711/lib/capistrano/tasks/deploy.rake)
|
236
246
|
after 'deploy:check:directories', 'psw_peppr_app_deploy:symlink_env_files'
|
237
247
|
|
248
|
+
desc "Deletes deployments older than the Capistrano keep_releases flag"
|
249
|
+
task :cleanup_old_deployments do
|
250
|
+
#only delete previous peppr deployments
|
251
|
+
if PepprAppDeployFileUtils::peppr_deployment?
|
252
|
+
keep_releases = fetch(:keep_releases, 5)
|
253
|
+
|
254
|
+
application_id = PepprAppDeployFileUtils::get_application_id
|
255
|
+
current_deployment = PepprAppDeployFileUtils::get_deployment_number
|
256
|
+
unless current_deployment.nil? || current_deployment < keep_releases
|
257
|
+
oldest_release_to_keep = current_deployment - keep_releases
|
258
|
+
while oldest_release_to_keep > 0 do
|
259
|
+
on roles(:app) do |host|
|
260
|
+
info "Removing remote deployment directories for application #{application_id}, deployment #{oldest_release_to_keep}..."
|
261
|
+
sudo :rm, '-rf', PepprAppDeployFileUtils::Remote::build_deployment_dir(application_id, oldest_release_to_keep)
|
262
|
+
end
|
263
|
+
|
264
|
+
run_locally do
|
265
|
+
info "Removing local deployment directories for application #{application_id}, deployment #{oldest_release_to_keep}..."
|
266
|
+
sudo :rm, '-rf', PepprAppDeployFileUtils::Local::build_deployment_dir(application_id, oldest_release_to_keep)
|
267
|
+
end
|
268
|
+
oldest_release_to_keep = oldest_release_to_keep - 1
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
#To save space (locally and remotely), delete deployments that are no longer referenced.
|
274
|
+
after 'deploy:cleanup', 'psw_peppr_app_deploy:cleanup_old_deployments'
|
275
|
+
|
238
276
|
end
|
@@ -12,51 +12,65 @@ namespace :check do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "psw_peppr_app_deploy:" do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Rake.application = rake
|
21
|
-
|
22
|
-
Rake.application.add_import("./resources/lib/capistrano/tasks/psw-peppr-app-deploy.cap")
|
23
|
-
Rake.application.load_imports()
|
24
|
-
end
|
15
|
+
before(:all) do
|
16
|
+
Rake.application = Rake::Application.new
|
17
|
+
Rake.application.add_import("./resources/lib/capistrano/tasks/psw-peppr-app-deploy.cap")
|
18
|
+
Rake.application.load_imports()
|
19
|
+
end
|
25
20
|
|
21
|
+
describe "#create_deployment_directories" do
|
26
22
|
it "has 'no prerequisites" do
|
23
|
+
subject = Rake.application["psw_peppr_app_deploy:create_deployment_directories"]
|
27
24
|
subject.prerequisites.should be_empty
|
28
25
|
end
|
29
26
|
end
|
27
|
+
|
28
|
+
describe "#upload_app_source_repo" do
|
29
|
+
it "has 'no prerequisites" do
|
30
|
+
subject = Rake.application["psw_peppr_app_deploy:upload_app_source_repo"]
|
31
|
+
subject.prerequisites.should be_empty
|
32
|
+
end
|
33
|
+
end
|
30
34
|
|
31
|
-
describe "
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Rake::Task.define_task('deploy:check:directories')
|
38
|
-
Rake.application.add_import("./resources/lib/capistrano/tasks/psw-peppr-app-deploy.cap")
|
39
|
-
Rake.application.load_imports()
|
40
|
-
end
|
35
|
+
describe "#upload_environment_files" do
|
36
|
+
it "has 'no prerequisites" do
|
37
|
+
subject = Rake.application["psw_peppr_app_deploy:upload_environment_files"]
|
38
|
+
subject.prerequisites.should be_empty
|
39
|
+
end
|
40
|
+
end
|
41
41
|
|
42
|
+
describe "#upload_artifacts" do
|
42
43
|
it "has 'no prerequisites" do
|
44
|
+
subject = Rake.application["psw_peppr_app_deploy:upload_artifacts"]
|
43
45
|
subject.prerequisites.should be_empty
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "upload_environment_files" do
|
48
|
-
let(:rake) { Rake::Application.new }
|
49
|
-
subject { rake["psw_peppr_app_deploy:upload_environment_files"] }
|
50
|
-
|
51
|
-
before do
|
52
|
-
Rake.application = rake
|
53
|
-
Rake::Task.define_task('deploy:check:directories')
|
54
|
-
Rake.application.add_import("./resources/lib/capistrano/tasks/psw-peppr-app-deploy.cap")
|
55
|
-
Rake.application.load_imports()
|
56
|
-
end
|
46
|
+
end
|
47
|
+
end
|
57
48
|
|
49
|
+
describe "#set_deploy_revision" do
|
58
50
|
it "has 'no prerequisites" do
|
51
|
+
subject = Rake.application["psw_peppr_app_deploy:set_deploy_revision"]
|
59
52
|
subject.prerequisites.should be_empty
|
60
|
-
end
|
61
|
-
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#link_artifacts" do
|
57
|
+
it "has 'no prerequisites" do
|
58
|
+
subject = Rake.application["psw_peppr_app_deploy:link_artifacts"]
|
59
|
+
subject.prerequisites.should be_empty
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#symlink_env_files" do
|
64
|
+
it "has 'no prerequisites" do
|
65
|
+
subject = Rake.application["psw_peppr_app_deploy:symlink_env_files"]
|
66
|
+
subject.prerequisites.should be_empty
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#cleanup_old_deployments" do
|
71
|
+
it "has 'no prerequisites" do
|
72
|
+
subject = Rake.application["psw_peppr_app_deploy:cleanup_old_deployments"]
|
73
|
+
subject.prerequisites.should be_empty
|
74
|
+
end
|
75
|
+
end
|
62
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-psw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.pre39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lexmark International Technology S.A
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|