avodeploy 0.4.2 → 0.5
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/CHANGELOG +20 -0
- data/README.md +1 -1
- data/avodeploy.gemspec +16 -14
- data/bin/avo +101 -104
- data/lib/avodeploy.rb +1 -0
- data/lib/avodeploy/bootstrap.rb +65 -73
- data/lib/avodeploy/command_execution_result.rb +6 -6
- data/lib/avodeploy/config.rb +120 -99
- data/lib/avodeploy/core_ext/string_colors.rb +9 -9
- data/lib/avodeploy/deployment.rb +43 -46
- data/lib/avodeploy/multi_io.rb +11 -11
- data/lib/avodeploy/scm_provider/bzr_scm_provider.rb +111 -0
- data/lib/avodeploy/scm_provider/git_scm_provider.rb +66 -45
- data/lib/avodeploy/scm_provider/scm_provider.rb +57 -43
- data/lib/avodeploy/skel/manifest_template.rb.erb +127 -116
- data/lib/avodeploy/strategy/base.rb +7 -7
- data/lib/avodeploy/strategy/local_copy.rb +99 -79
- data/lib/avodeploy/strategy/local_copy_partial.rb +86 -0
- data/lib/avodeploy/target.rb +32 -31
- data/lib/avodeploy/task/local_task_execution_environment.rb +112 -107
- data/lib/avodeploy/task/remote_task_execution_environment.rb +90 -94
- data/lib/avodeploy/task/task.rb +53 -42
- data/lib/avodeploy/task/task_dependency.rb +5 -5
- data/lib/avodeploy/task/task_execution_environment.rb +70 -59
- data/lib/avodeploy/task/task_manager.rb +187 -165
- data/lib/avodeploy/version.rb +1 -1
- metadata +7 -5
@@ -17,57 +17,78 @@
|
|
17
17
|
=end
|
18
18
|
|
19
19
|
module AvoDeploy
|
20
|
-
|
21
|
-
|
20
|
+
module ScmProvider
|
21
|
+
class GitScmProvider < ScmProvider
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
# Initializes the provider
|
24
|
+
#
|
25
|
+
# @param env [TaskExecutionEnvironment] Environment for the commands to be executed in
|
26
|
+
def initialize(env)
|
27
|
+
super(env)
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
res = @env.command("git clone #{url} #{local_dir}")
|
39
|
-
raise RuntimeError, "Could not clone from git url #{url}" unless res.retval == 0
|
30
|
+
# Checks out repository code from a system and switches to the given branch
|
31
|
+
#
|
32
|
+
# @param url [String] the repository location
|
33
|
+
# @param local_dir [String] path to the working copy
|
34
|
+
# @param branch [String] the branch to check out
|
35
|
+
# @param tag [String] tag to check out
|
36
|
+
def checkout_from_remote(url, local_dir, branch, tag = nil)
|
37
|
+
res = @env.command("git clone #{url} #{local_dir}")
|
38
|
+
raise RuntimeError, "Could not clone from git url #{url}" unless res.retval == 0
|
40
39
|
|
41
|
-
|
42
|
-
res = @env.command("git checkout #{branch}")
|
43
|
-
@env.chdir('../')
|
44
|
-
|
45
|
-
raise RuntimeError, "could not switch to branch #{branch}" unless res.retval == 0
|
46
|
-
end
|
40
|
+
branch = tag if tag.nil? == false
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def revision
|
52
|
-
res = @env.command("git rev-parse HEAD")
|
42
|
+
@env.chdir(local_dir)
|
43
|
+
res = @env.command("git checkout #{branch}")
|
44
|
+
@env.chdir('../')
|
53
45
|
|
54
|
-
|
55
|
-
|
46
|
+
raise RuntimeError, "could not switch to branch #{branch}" unless res.retval == 0
|
47
|
+
end
|
56
48
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
49
|
+
# Returns the current revision of the working copy
|
50
|
+
#
|
51
|
+
# @return [String] the current revision of the working copy
|
52
|
+
def revision
|
53
|
+
res = @env.command('git rev-parse HEAD')
|
54
|
+
res.stdout.gsub("\n", '')
|
55
|
+
end
|
63
56
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
57
|
+
# Finds files that differ between two revisions and returns them
|
58
|
+
# as a array
|
59
|
+
#
|
60
|
+
# @param rev1 [String] sha1
|
61
|
+
# @param rev2 [String] sha1
|
62
|
+
#
|
63
|
+
# @return [Array]
|
64
|
+
def diff_files_between_revisions(rev1, rev2)
|
65
|
+
res = @env.command("git diff --name-only #{rev1} #{rev2}")
|
66
|
+
res.stdout.lines
|
67
|
+
end
|
70
68
|
|
71
|
-
|
72
|
-
|
69
|
+
# Finds files unknown file in the working directory and returns them
|
70
|
+
# as a array
|
71
|
+
#
|
72
|
+
# @return [Array]
|
73
|
+
def unknown_files_in_workdir
|
74
|
+
res = @env.command("git status -s | grep '^??' | awk '/^?? (.*)$/ {print $2}'")
|
75
|
+
res.stdout.lines
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns scm files to be executed in the deployment process
|
79
|
+
#
|
80
|
+
# @return [Array] array of scm control files
|
81
|
+
def scm_files
|
82
|
+
['.git', '.gitignore']
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the scm tools that have to be installed on specific systems
|
86
|
+
#
|
87
|
+
# @return [Array] array of utilities
|
88
|
+
def cli_utils
|
89
|
+
['git', 'awk', 'grep']
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
73
94
|
end
|
@@ -17,54 +17,68 @@
|
|
17
17
|
=end
|
18
18
|
|
19
19
|
module AvoDeploy
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
module ScmProvider
|
21
|
+
# scm provider base class
|
22
|
+
class ScmProvider
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise ArgumentError, 'env must be a TaskExecutionEnvironment' unless env.is_a?(AvoDeploy::Task::TaskExecutionEnvironment)
|
24
|
+
# Initializes the scm provider
|
25
|
+
#
|
26
|
+
# @param env [TaskExecutionEnvironment] env for the commands to be executed in
|
27
|
+
def initialize(env)
|
28
|
+
raise ArgumentError, 'env must be a TaskExecutionEnvironment' unless env.is_a?(AvoDeploy::Task::TaskExecutionEnvironment)
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
@env = env
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
# Checks out repository code from a system and switches to the given branch
|
34
|
+
#
|
35
|
+
# @param url [String] the repository location
|
36
|
+
# @param local_dir [String] path to the working copy
|
37
|
+
# @param branch [String] the branch to check out
|
38
|
+
# @param tag [String] tag to check out
|
39
|
+
def checkout_from_remote(url, local_dir, branch, tag = nil)
|
40
|
+
raise NotImplementedError
|
41
|
+
end
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
# Finds files that differ between two revisions and returns them
|
44
|
+
# as a array
|
45
|
+
#
|
46
|
+
# @param rev1 [String] sha1
|
47
|
+
# @param rev2 [String] sha1
|
48
|
+
#
|
49
|
+
# @return [Array]
|
50
|
+
def diff_files_between_revisions(rev1, rev2)
|
51
|
+
raise NotImplementedError
|
52
|
+
end
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
# Finds files unknown file in the working directory and returns them
|
55
|
+
# as a array
|
56
|
+
#
|
57
|
+
# @return [Array]
|
58
|
+
def unknown_files_in_workdir
|
59
|
+
raise NotImplementedError
|
60
|
+
end
|
54
61
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
62
|
+
# Returns the current revision of the working copy
|
63
|
+
#
|
64
|
+
# @return [String] the current revision of the working copy
|
65
|
+
def scm_files
|
66
|
+
raise NotImplementedError
|
67
|
+
end
|
61
68
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
# Returns scm files to be executed in the deployment process
|
70
|
+
#
|
71
|
+
# @return [Array] array of scm control files
|
72
|
+
def cli_utils
|
73
|
+
raise NotImplementedError
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns the scm tools that have to be installed on specific systems
|
77
|
+
#
|
78
|
+
# @return [Array] array of utilities
|
79
|
+
def revision
|
80
|
+
raise NotImplementedError
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
70
84
|
end
|
@@ -1,117 +1,128 @@
|
|
1
|
-
AvoDeploy::Deployment.configure do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
1
|
+
AvoDeploy::Deployment.configure do
|
2
|
+
|
3
|
+
# AVOCADO
|
4
|
+
# The flexible and easy to use deployment framework for web applications
|
5
|
+
#
|
6
|
+
# Welcome to your deployment manifest. Here you can configure the
|
7
|
+
# whole deployment process of your application to various target systems.
|
8
|
+
# This is a example file that has been created by `avo install`.
|
9
|
+
# While you are presented with the common configuration options for
|
10
|
+
# most common use cases, there are plenty more available and you might want
|
11
|
+
# to check them out. Because of the fact, that, currently, there is no
|
12
|
+
# official documentation, you have to lookup all the configuration options
|
13
|
+
# right in the applications' source code. But don't be afraid, you'll find
|
14
|
+
# them all in one place. Just take a look in the `config.rb` file at the
|
15
|
+
# method called `setup_config_defaults`.
|
16
|
+
#
|
17
|
+
|
18
|
+
# =============== GENERAL PROJECT CONFIGURATION ==================
|
19
|
+
# Set your project name here. This is not used right now but may
|
20
|
+
# be used for various purposes in future releases.
|
21
|
+
#
|
22
|
+
set :project_name, 'myproject'
|
23
|
+
|
24
|
+
# ===================== SCM CONFIGURATION ========================
|
25
|
+
# Configure the version control software you use for your project.
|
26
|
+
# Currently only Git and Bazaar are supported, but this will change
|
27
|
+
# in the future.
|
28
|
+
#
|
29
|
+
# Valid options:
|
30
|
+
# :git
|
31
|
+
# :bzr
|
32
|
+
#
|
33
|
+
set :scm, :git
|
34
|
+
|
35
|
+
# This is your repository url
|
36
|
+
#
|
37
|
+
set :repo_url, 'foo@github.com:foo/myproject.git'
|
38
|
+
|
39
|
+
# Specify the branch you'd like to deploy here. By default this is
|
40
|
+
# set to :master but could be every branch you wish. If your branch
|
41
|
+
# name contains special characters like slashes, just use a
|
42
|
+
# string rather than a symbol.
|
43
|
+
#
|
44
|
+
# Examples:
|
45
|
+
# :master
|
46
|
+
# :develop
|
47
|
+
# 'feature/AVO-123_manifest'
|
48
|
+
#
|
49
|
+
set :branch, :master
|
50
|
+
|
51
|
+
# ==================== DEPLOYMENT STRATEGY =======================
|
52
|
+
# Set your deployment strategy here. Currently only `local_copy`
|
53
|
+
# is implemented. The additional configuration values depend on
|
54
|
+
# the selected strategy.
|
55
|
+
#
|
56
|
+
# >= 0.5: To use multiple strategies, use
|
57
|
+
# `inherit_strategy :local_copy
|
58
|
+
# inherit_strategy :some_other_strategy`
|
59
|
+
#
|
60
|
+
# `local_copy`: Files are checked out of version control into a
|
61
|
+
# local directory, eventually preprocess and then
|
62
|
+
# packed (tarball), uploaded (via scp) and unpacked
|
63
|
+
# on the target system.
|
64
|
+
#
|
65
|
+
# `local_copy_partial`: Same as `local_copy` but uploads only files
|
66
|
+
# that have changed since the last deployment
|
67
|
+
# to the specific target system.
|
68
|
+
#
|
69
|
+
# Valid options:
|
70
|
+
# :local_copy
|
71
|
+
# :local_copy_partial
|
72
|
+
#
|
73
|
+
set :strategy, :local_copy
|
74
|
+
|
75
|
+
# Files to be ignored for the deployment process. Those files will
|
76
|
+
# not be overwritten on the target system
|
77
|
+
#
|
78
|
+
set :ignore_files, ['.htaccess']
|
79
|
+
|
80
|
+
# ================= ADDITIONAL TASK DEFINITION ====================
|
81
|
+
# Avocado consists of a task system. Every step that is done while
|
82
|
+
# the deployment process is represented as a task definition.
|
83
|
+
# Due to the fact that most of the tasks depend on each other
|
84
|
+
# tasks can be related into a chain of tasks. When you call a task
|
85
|
+
# from the CLI utility, the whole chain for this task will be executed.
|
86
|
+
# This is a powerful tool for you to customize the deployment process
|
87
|
+
# for your needs. A full list of which tasks are defined and where you
|
88
|
+
# can hook on to do this or that can be found in the definition of each
|
89
|
+
# strategy in the `strategy/` directory.
|
90
|
+
#
|
91
|
+
# A basic task definition can look like that:
|
92
|
+
#
|
93
|
+
# task :do_that do
|
94
|
+
# command "echo 'foo'"
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# This task has no relations and therefore has to be called directly via
|
98
|
+
# the CLI interface. When you call `avo start staging do_that` this task
|
99
|
+
# would execute the command `echo 'foo'` LOCALLY, because no `scope` is defined.
|
100
|
+
# Take a look at the following code to see a fully featured example in action.
|
101
|
+
#
|
102
|
+
# task :install_composer, before: :create_deployment_tarball, scope: :local, desc: "installs the composer" do
|
103
|
+
# command "php composer.phar install"
|
104
|
+
# end
|
105
|
+
|
106
|
+
# ==================== STAGES CONFIGURATION =======================
|
107
|
+
|
108
|
+
<% stages.each do |stage| %>
|
109
|
+
setup_stage :<%= stage %>, desc: "Configuration for '<%= stage %>'" do
|
110
|
+
# In this section you can overwrite every configuration choice
|
111
|
+
# you have made above. You can define additional tasks, that
|
112
|
+
# are only usable within the current scope or change the
|
113
|
+
# repository url or branch for your current needs.
|
114
|
+
#
|
115
|
+
|
116
|
+
# ============== TARGET SYSTEM CONFIGURATION =================
|
117
|
+
# Files are transmitted over SCP. Therefore you must configure
|
118
|
+
# your target systems' SSH access credentials.
|
119
|
+
#
|
120
|
+
|
121
|
+
# Currently only pubkey-auth is supported
|
122
|
+
#
|
123
|
+
target :web, host: 'my.host.tld', port: 22, user: 'deploy', auth: :pubkey, deploy_dir: '/var/www/staging/'
|
124
|
+
end
|
125
|
+
<% end %>
|
126
|
+
|
127
|
+
|
117
128
|
end
|