capistrano 2.8.0 → 3.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/.docker/Dockerfile +7 -0
  3. data/.docker/ssh_key_rsa +49 -0
  4. data/.docker/ssh_key_rsa.pub +1 -0
  5. data/.docker/ubuntu_setup.sh +23 -0
  6. data/.github/issue_template.md +19 -0
  7. data/.github/pull_request_template.md +22 -0
  8. data/.github/release-drafter.yml +25 -0
  9. data/.github/workflows/ci.yml +80 -0
  10. data/.github/workflows/release-drafter.yml +18 -0
  11. data/.gitignore +23 -8
  12. data/.rubocop.yml +62 -0
  13. data/CHANGELOG.md +1 -0
  14. data/CONTRIBUTING.md +63 -0
  15. data/DEVELOPMENT.md +112 -0
  16. data/Gemfile +42 -9
  17. data/LICENSE.txt +21 -0
  18. data/README.md +221 -0
  19. data/RELEASING.md +17 -0
  20. data/Rakefile +17 -8
  21. data/UPGRADING-3.7.md +86 -0
  22. data/bin/cap +2 -3
  23. data/bin/capify +7 -89
  24. data/capistrano.gemspec +29 -43
  25. data/docker-compose.yml +8 -0
  26. data/features/configuration.feature +28 -0
  27. data/features/deploy.feature +92 -0
  28. data/features/deploy_failure.feature +17 -0
  29. data/features/doctor.feature +11 -0
  30. data/features/installation.feature +21 -0
  31. data/features/sshconnect.feature +11 -0
  32. data/features/stage_failure.feature +9 -0
  33. data/features/step_definitions/assertions.rb +162 -0
  34. data/features/step_definitions/cap_commands.rb +21 -0
  35. data/features/step_definitions/setup.rb +91 -0
  36. data/features/subdirectory.feature +9 -0
  37. data/features/support/docker_gateway.rb +53 -0
  38. data/features/support/env.rb +1 -0
  39. data/features/support/remote_command_helpers.rb +29 -0
  40. data/features/support/remote_ssh_helpers.rb +33 -0
  41. data/lib/Capfile +3 -0
  42. data/lib/capistrano/all.rb +17 -0
  43. data/lib/capistrano/application.rb +153 -0
  44. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  45. data/lib/capistrano/configuration/filter.rb +26 -0
  46. data/lib/capistrano/configuration/host_filter.rb +29 -0
  47. data/lib/capistrano/configuration/null_filter.rb +9 -0
  48. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  49. data/lib/capistrano/configuration/question.rb +76 -0
  50. data/lib/capistrano/configuration/role_filter.rb +29 -0
  51. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  52. data/lib/capistrano/configuration/server.rb +137 -0
  53. data/lib/capistrano/configuration/servers.rb +56 -96
  54. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  55. data/lib/capistrano/configuration/variables.rb +79 -94
  56. data/lib/capistrano/configuration.rb +178 -33
  57. data/lib/capistrano/console.rb +1 -0
  58. data/lib/capistrano/defaults.rb +36 -0
  59. data/lib/capistrano/deploy.rb +3 -0
  60. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  61. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  62. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  63. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  64. data/lib/capistrano/doctor/variables_doctor.rb +74 -0
  65. data/lib/capistrano/doctor.rb +6 -0
  66. data/lib/capistrano/dotfile.rb +2 -0
  67. data/lib/capistrano/dsl/env.rb +43 -0
  68. data/lib/capistrano/dsl/paths.rb +89 -0
  69. data/lib/capistrano/dsl/stages.rb +31 -0
  70. data/lib/capistrano/dsl/task_enhancements.rb +61 -0
  71. data/lib/capistrano/dsl.rb +95 -0
  72. data/lib/capistrano/framework.rb +2 -0
  73. data/lib/capistrano/i18n.rb +46 -0
  74. data/lib/capistrano/immutable_task.rb +30 -0
  75. data/lib/capistrano/install.rb +1 -0
  76. data/lib/capistrano/plugin.rb +95 -0
  77. data/lib/capistrano/proc_helpers.rb +13 -0
  78. data/lib/capistrano/scm/git.rb +105 -0
  79. data/lib/capistrano/scm/hg.rb +55 -0
  80. data/lib/capistrano/scm/plugin.rb +13 -0
  81. data/lib/capistrano/scm/svn.rb +56 -0
  82. data/lib/capistrano/scm/tasks/git.rake +84 -0
  83. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  84. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  85. data/lib/capistrano/scm.rb +115 -0
  86. data/lib/capistrano/setup.rb +36 -0
  87. data/lib/capistrano/tasks/console.rake +25 -0
  88. data/lib/capistrano/tasks/deploy.rake +280 -0
  89. data/lib/capistrano/tasks/doctor.rake +24 -0
  90. data/lib/capistrano/tasks/framework.rake +67 -0
  91. data/lib/capistrano/tasks/install.rake +41 -0
  92. data/lib/capistrano/templates/Capfile +38 -0
  93. data/lib/capistrano/templates/deploy.rb.erb +39 -0
  94. data/lib/capistrano/templates/stage.rb.erb +61 -0
  95. data/lib/capistrano/upload_task.rb +9 -0
  96. data/lib/capistrano/version.rb +1 -14
  97. data/lib/capistrano/version_validator.rb +32 -0
  98. data/lib/capistrano.rb +0 -3
  99. data/spec/integration/dsl_spec.rb +632 -0
  100. data/spec/integration_spec_helper.rb +5 -0
  101. data/spec/lib/capistrano/application_spec.rb +60 -0
  102. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  103. data/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
  104. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  105. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  106. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  107. data/spec/lib/capistrano/configuration/question_spec.rb +92 -0
  108. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  109. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
  110. data/spec/lib/capistrano/configuration/server_spec.rb +309 -0
  111. data/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
  112. data/spec/lib/capistrano/configuration_spec.rb +357 -0
  113. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  114. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  115. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  116. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  117. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  118. data/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
  119. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
  120. data/spec/lib/capistrano/dsl_spec.rb +125 -0
  121. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  122. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  123. data/spec/lib/capistrano/scm/git_spec.rb +194 -0
  124. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  125. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  126. data/spec/lib/capistrano/scm_spec.rb +103 -0
  127. data/spec/lib/capistrano/upload_task_spec.rb +19 -0
  128. data/spec/lib/capistrano/version_validator_spec.rb +118 -0
  129. data/spec/lib/capistrano_spec.rb +7 -0
  130. data/spec/spec_helper.rb +29 -0
  131. data/spec/support/matchers.rb +5 -0
  132. data/spec/support/tasks/database.rake +11 -0
  133. data/spec/support/tasks/fail.rake +8 -0
  134. data/spec/support/tasks/failed.rake +5 -0
  135. data/spec/support/tasks/plugin.rake +6 -0
  136. data/spec/support/tasks/root.rake +11 -0
  137. data/spec/support/test_app.rb +205 -0
  138. metadata +234 -208
  139. data/.rvmrc +0 -1
  140. data/CHANGELOG +0 -954
  141. data/README.mdown +0 -76
  142. data/lib/capistrano/callback.rb +0 -45
  143. data/lib/capistrano/cli/execute.rb +0 -85
  144. data/lib/capistrano/cli/help.rb +0 -125
  145. data/lib/capistrano/cli/help.txt +0 -81
  146. data/lib/capistrano/cli/options.rb +0 -243
  147. data/lib/capistrano/cli/ui.rb +0 -40
  148. data/lib/capistrano/cli.rb +0 -47
  149. data/lib/capistrano/command.rb +0 -286
  150. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -51
  151. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  152. data/lib/capistrano/configuration/actions/invocation.rb +0 -298
  153. data/lib/capistrano/configuration/callbacks.rb +0 -148
  154. data/lib/capistrano/configuration/connections.rb +0 -230
  155. data/lib/capistrano/configuration/execution.rb +0 -143
  156. data/lib/capistrano/configuration/loading.rb +0 -197
  157. data/lib/capistrano/configuration/namespaces.rb +0 -197
  158. data/lib/capistrano/configuration/roles.rb +0 -73
  159. data/lib/capistrano/errors.rb +0 -19
  160. data/lib/capistrano/ext/string.rb +0 -5
  161. data/lib/capistrano/extensions.rb +0 -57
  162. data/lib/capistrano/logger.rb +0 -59
  163. data/lib/capistrano/processable.rb +0 -53
  164. data/lib/capistrano/recipes/compat.rb +0 -32
  165. data/lib/capistrano/recipes/deploy/assets.rb +0 -57
  166. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  167. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
  168. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -111
  169. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  170. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -196
  171. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  172. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
  173. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
  174. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -282
  175. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
  176. data/lib/capistrano/recipes/deploy/scm/none.rb +0 -44
  177. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -138
  178. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
  179. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  180. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -88
  181. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  182. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -224
  183. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  184. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  185. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
  186. data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
  187. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
  188. data/lib/capistrano/recipes/deploy.rb +0 -568
  189. data/lib/capistrano/recipes/standard.rb +0 -37
  190. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  191. data/lib/capistrano/role.rb +0 -102
  192. data/lib/capistrano/server_definition.rb +0 -56
  193. data/lib/capistrano/shell.rb +0 -260
  194. data/lib/capistrano/ssh.rb +0 -101
  195. data/lib/capistrano/task_definition.rb +0 -75
  196. data/lib/capistrano/transfer.rb +0 -216
  197. data/rvmrc.sample +0 -1
  198. data/test/cli/execute_test.rb +0 -132
  199. data/test/cli/help_test.rb +0 -165
  200. data/test/cli/options_test.rb +0 -329
  201. data/test/cli/ui_test.rb +0 -28
  202. data/test/cli_test.rb +0 -17
  203. data/test/command_test.rb +0 -289
  204. data/test/configuration/actions/file_transfer_test.rb +0 -61
  205. data/test/configuration/actions/inspect_test.rb +0 -65
  206. data/test/configuration/actions/invocation_test.rb +0 -247
  207. data/test/configuration/callbacks_test.rb +0 -220
  208. data/test/configuration/connections_test.rb +0 -420
  209. data/test/configuration/execution_test.rb +0 -175
  210. data/test/configuration/loading_test.rb +0 -132
  211. data/test/configuration/namespace_dsl_test.rb +0 -311
  212. data/test/configuration/roles_test.rb +0 -144
  213. data/test/configuration/servers_test.rb +0 -183
  214. data/test/configuration/variables_test.rb +0 -190
  215. data/test/configuration_test.rb +0 -88
  216. data/test/deploy/local_dependency_test.rb +0 -76
  217. data/test/deploy/remote_dependency_test.rb +0 -135
  218. data/test/deploy/scm/accurev_test.rb +0 -23
  219. data/test/deploy/scm/base_test.rb +0 -55
  220. data/test/deploy/scm/bzr_test.rb +0 -51
  221. data/test/deploy/scm/darcs_test.rb +0 -37
  222. data/test/deploy/scm/git_test.rb +0 -184
  223. data/test/deploy/scm/mercurial_test.rb +0 -134
  224. data/test/deploy/scm/none_test.rb +0 -35
  225. data/test/deploy/scm/subversion_test.rb +0 -32
  226. data/test/deploy/strategy/copy_test.rb +0 -321
  227. data/test/extensions_test.rb +0 -69
  228. data/test/fixtures/cli_integration.rb +0 -5
  229. data/test/fixtures/config.rb +0 -5
  230. data/test/fixtures/custom.rb +0 -3
  231. data/test/logger_test.rb +0 -123
  232. data/test/recipes_test.rb +0 -25
  233. data/test/role_test.rb +0 -11
  234. data/test/server_definition_test.rb +0 -121
  235. data/test/shell_test.rb +0 -90
  236. data/test/ssh_test.rb +0 -113
  237. data/test/task_definition_test.rb +0 -116
  238. data/test/transfer_test.rb +0 -160
  239. data/test/utils.rb +0 -37
data/README.md ADDED
@@ -0,0 +1,221 @@
1
+
2
+ # Capistrano: A deployment automation tool built on Ruby, Rake, and SSH.
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/capistrano.svg)](http://badge.fury.io/rb/capistrano) [![Build Status](https://github.com/capistrano/capistrano/actions/workflows/ci.yml/badge.svg)](https://github.com/capistrano/capistrano/actions/workflows/ci.yml) [![Code Climate](https://codeclimate.com/github/capistrano/capistrano/badges/gpa.svg)](https://codeclimate.com/github/capistrano/capistrano) [![CodersClan](https://img.shields.io/badge/get-support-blue.svg)](http://codersclan.net/?repo_id=325&source=small)
5
+
6
+ Capistrano is a framework for building automated deployment scripts. Although Capistrano itself is written in Ruby, it can easily be used to deploy projects of any language or framework, be it Rails, Java, or PHP.
7
+
8
+ Once installed, Capistrano gives you a `cap` tool to perform your deployments from the comfort of your command line.
9
+
10
+ ```
11
+ $ cd my-capistrano-enabled-project
12
+ $ cap production deploy
13
+ ```
14
+
15
+ When you run `cap`, Capistrano dutifully connects to your server(s) via SSH and executes the steps necessary to deploy your project. You can define those steps yourself by writing [Rake](https://github.com/ruby/rake) tasks, or by using pre-built task libraries provided by the Capistrano community.
16
+
17
+ Tasks are simple to make. Here's an example:
18
+
19
+ ```ruby
20
+ task :restart_sidekiq do
21
+ on roles(:worker) do
22
+ execute :service, "sidekiq restart"
23
+ end
24
+ end
25
+ after "deploy:published", "restart_sidekiq"
26
+ ```
27
+
28
+ *Note: This documentation is for the current version of Capistrano (3.x). If you are looking for Capistrano 2.x documentation, you can find it in [this archive](https://github.com/capistrano/capistrano-2.x-docs).*
29
+
30
+ ---
31
+
32
+ ## Contents
33
+
34
+ * [Features](#features)
35
+ * [Gotchas](#gotchas)
36
+ * [Quick start](#quick-start)
37
+ * [Finding help and documentation](#finding-help-and-documentation)
38
+ * [How to contribute](#how-to-contribute)
39
+ * [License](#license)
40
+
41
+ ## Features
42
+
43
+ There are many ways to automate deployments, from simple rsync bash scripts to complex containerized toolchains. Capistrano sits somewhere in the middle: it automates what you already know how to do manually with SSH, but in a repeatable, scalable fashion. There is no magic here!
44
+
45
+ Here's what makes Capistrano great:
46
+
47
+ #### Strong conventions
48
+
49
+ Capistrano defines a standard deployment process that all Capistrano-enabled projects follow by default. You don't have to decide how to structure your scripts, where deployed files should be placed on the server, or how to perform common tasks: Capistrano has done this work for you.
50
+
51
+ #### Multiple stages
52
+
53
+ Define your deployment once, and then easily parameterize it for multiple *stages* (environments), e.g. `qa`, `staging`, and `production`. No copy-and-paste necessary: you only need to specify what is different for each stage, like IP addresses.
54
+
55
+ #### Parallel execution
56
+
57
+ Deploying to a fleet of app servers? Capistrano can run each deployment task concurrently across those servers and uses connection pooling for speed.
58
+
59
+ #### Server roles
60
+
61
+ Your application may need many different types of servers: a database server, an app server, two web servers, and a job queue work server, for example. Capistrano lets you tag each server with one or more roles, so you can control what tasks are executed where.
62
+
63
+ #### Community driven
64
+
65
+ Capistrano is easily extensible using the rubygems package manager. Deploying a Rails app? Wordpress? Laravel? Chances are, someone has already written Capistrano tasks for your framework of choice and has distributed it as a gem. Many Ruby projects also come with Capistrano tasks built-in.
66
+
67
+ #### It's just SSH
68
+
69
+ Everything in Capistrano comes down to running SSH commands on remote servers. On the one hand, that makes Capistrano simple. On the other hand, if you aren't comfortable SSH-ing into a Linux box and doing stuff on the command-line, then Capistrano is probably not for you.
70
+
71
+ ## Gotchas
72
+
73
+ While Capistrano ships with a strong set of conventions that are common for all types of deployments, it needs help understanding the specifics of your project, and there are some things Capistrano is not suited to do.
74
+
75
+ #### Project specifics
76
+
77
+ Out of the box, Capistrano can deploy your code to server(s), but it does not know how to *execute* your code. Does `foreman` need to be run? Does Apache need to be restarted? You'll need to tell Capistrano how to do this part by writing these deployment steps yourself, or by finding a gem in the Capistrano community that does it for you.
78
+
79
+ #### Key-based SSH
80
+
81
+ Capistrano depends on connecting to your server(s) with SSH using key-based (i.e. password-less) authentication. You'll need this working before you can use Capistrano.
82
+
83
+ #### Provisioning
84
+
85
+ Likewise, your server(s) will likely need supporting software installed before you can perform a deployment. Capistrano itself has no requirements other than SSH, but your application probably needs database software, a web server like Apache or Nginx, and a language runtime like Java, Ruby, or PHP. These *server provisioning* steps are not done by Capistrano.
86
+
87
+ #### `sudo`, etc.
88
+
89
+ Capistrano is designed to deploy using a single, non-privileged SSH user, using a *non-interactive* SSH session. If your deployment requires `sudo`, interactive prompts, authenticating as one user but running commands as another, you can probably accomplish this with Capistrano, but it may be difficult. Your automated deployments will be much smoother if you can avoid such requirements.
90
+
91
+ #### Shells
92
+
93
+ Capistrano 3 expects a POSIX shell like Bash or Sh. Shells like tcsh, csh, and such may work, but probably will not.
94
+
95
+ ## Quick start
96
+
97
+ ### Requirements
98
+
99
+ * Ruby version 2.0 or higher on your local machine (MRI or Rubinius)
100
+ * A project that uses source control (Git, Mercurial, and Subversion support is built-in)
101
+ * The SCM binaries (e.g. `git`, `hg`) needed to check out your project must be installed on the server(s) you are deploying to
102
+ * [Bundler](http://bundler.io), along with a Gemfile for your project, are recommended
103
+
104
+ ### Install the Capistrano gem
105
+
106
+ Add Capistrano to your project's Gemfile using `require: false`:
107
+
108
+ ``` ruby
109
+ group :development do
110
+ gem "capistrano", "~> 3.17", require: false
111
+ end
112
+ ```
113
+
114
+ Then run Bundler to ensure Capistrano is downloaded and installed:
115
+
116
+ ``` sh
117
+ $ bundle install
118
+ ```
119
+
120
+ ### "Capify" your project
121
+
122
+ Make sure your project doesn't already have a "Capfile" or "capfile" present. Then run:
123
+
124
+ ``` sh
125
+ $ bundle exec cap install
126
+ ```
127
+
128
+ This creates all the necessary configuration files and directory structure for a Capistrano-enabled project with two stages, `staging` and `production`:
129
+
130
+ ```
131
+ ├── Capfile
132
+ ├── config
133
+ │ ├── deploy
134
+ │ │ ├── production.rb
135
+ │ │ └── staging.rb
136
+ │ └── deploy.rb
137
+ └── lib
138
+ └── capistrano
139
+ └── tasks
140
+ ```
141
+
142
+ To customize the stages that are created, use:
143
+
144
+ ``` sh
145
+ $ bundle exec cap install STAGES=local,sandbox,qa,production
146
+ ```
147
+
148
+ Note that the files that Capistrano creates are simply templates to get you started. Make sure to edit the `deploy.rb` and stage files so that they contain values appropriate for your project and your target servers.
149
+
150
+ ### Command-line usage
151
+
152
+ ``` sh
153
+ # list all available tasks
154
+ $ bundle exec cap -T
155
+
156
+ # deploy to the staging environment
157
+ $ bundle exec cap staging deploy
158
+
159
+ # deploy to the production environment
160
+ $ bundle exec cap production deploy
161
+
162
+ # simulate deploying to the production environment
163
+ # does not actually do anything
164
+ $ bundle exec cap production deploy --dry-run
165
+
166
+ # list task dependencies
167
+ $ bundle exec cap production deploy --prereqs
168
+
169
+ # trace through task invocations
170
+ $ bundle exec cap production deploy --trace
171
+
172
+ # lists all config variable before deployment tasks
173
+ $ bundle exec cap production deploy --print-config-variables
174
+ ```
175
+
176
+ ## Finding help and documentation
177
+
178
+ Capistrano is a large project encompassing multiple GitHub repositories and a community of plugins, and it can be overwhelming when you are just getting started. Here are resources that can help:
179
+
180
+ * **The [docs](docs) directory contains the official documentation**, and is used to generate the [Capistrano website](http://capistranorb.com)
181
+ * [Stack Overflow](http://stackoverflow.com/questions/tagged/capistrano) has a Capistrano tag with lots of activity
182
+ * [The Capistrano mailing list](https://groups.google.com/forum/#!forum/capistrano) is low-traffic but is monitored by Capistrano contributors
183
+ * [CodersClan](http://codersclan.net/?repo_id=325&source=link) has Capistrano experts available to solve problems for bounties
184
+
185
+ Related GitHub repositories:
186
+
187
+ * [capistrano/sshkit](https://github.com/capistrano/sshkit) provides the SSH behavior that underlies Capistrano (when you use `execute` in a Capistrano task, you are using SSHKit)
188
+ * [capistrano/rails](https://github.com/capistrano/rails) is a very popular gem that adds Ruby on Rails deployment tasks
189
+ * [mattbrictson/airbrussh](https://github.com/mattbrictson/airbrussh) provides Capistrano's default log formatting
190
+
191
+ GitHub issues are for bug reports and feature requests. Please refer to the [CONTRIBUTING](CONTRIBUTING.md) document for guidelines on submitting GitHub issues.
192
+
193
+ If you think you may have discovered a security vulnerability in Capistrano, do not open a GitHub issue. Instead, please send a report to <security@capistranorb.com>.
194
+
195
+ ## How to contribute
196
+
197
+ Contributions to Capistrano, in the form of code, documentation or idea, are gladly accepted. Read the [DEVELOPMENT](DEVELOPMENT.md) document to learn how to hack on Capistrano's code, run the tests, and contribute your first pull request.
198
+
199
+ ## License
200
+
201
+ MIT License (MIT)
202
+
203
+ Copyright (c) 2012-2020 Tom Clements, Lee Hambley
204
+
205
+ Permission is hereby granted, free of charge, to any person obtaining a copy
206
+ of this software and associated documentation files (the "Software"), to deal
207
+ in the Software without restriction, including without limitation the rights
208
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
209
+ copies of the Software, and to permit persons to whom the Software is
210
+ furnished to do so, subject to the following conditions:
211
+
212
+ The above copyright notice and this permission notice shall be included in
213
+ all copies or substantial portions of the Software.
214
+
215
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
216
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
217
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
218
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
219
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
220
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
221
+ THE SOFTWARE.
data/RELEASING.md ADDED
@@ -0,0 +1,17 @@
1
+ # Releasing
2
+
3
+ ## Prerequisites
4
+
5
+ * You must have commit rights to the Capistrano repository.
6
+ * You must have push rights for the capistrano gem on rubygems.org.
7
+
8
+ ## How to release
9
+
10
+ 1. Run `bundle install` to make sure that you have all the gems necessary for testing and releasing.
11
+ 2. **Ensure all tests are passing by running `rake spec` and `rake features`.**
12
+ 3. Determine which would be the correct next version number according to [semver](http://semver.org/).
13
+ 4. Update the version in `./lib/capistrano/version.rb`.
14
+ 5. Update the version in the `./README.md` Gemfile example (`gem "capistrano", "~> X.Y"`).
15
+ 6. Commit the `version.rb` and `README.md` changes in a single commit, the message should be "Release vX.Y.Z"
16
+ 7. Run `rake release`; this will tag, push to GitHub, and publish to rubygems.org.
17
+ 8. Update the draft release on the [GitHub releases page](https://github.com/capistrano/capistrano/releases) to point to the new tag and publish the release
data/Rakefile CHANGED
@@ -1,11 +1,20 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
1
+ require "bundler/gem_tasks"
2
+ require "cucumber/rake/task"
3
+ require "rspec/core/rake_task"
3
4
 
4
- require 'rake/testtask'
5
- Rake::TestTask.new(:test) do |test|
6
- test.libs << 'lib' << 'test'
7
- test.pattern = 'test/**/*_test.rb'
8
- test.verbose = true
5
+ begin
6
+ require "rubocop/rake_task"
7
+ desc "Run RuboCop checks"
8
+ RuboCop::RakeTask.new
9
+ task default: %i(spec rubocop)
10
+ rescue LoadError
11
+ task default: :spec
9
12
  end
10
13
 
11
- task :default => :test
14
+ RSpec::Core::RakeTask.new
15
+ Cucumber::Rake::Task.new(:features)
16
+
17
+ Rake::Task["release"].enhance do
18
+ puts "Don't forget to publish the release on GitHub!"
19
+ system "open https://github.com/capistrano/capistrano/releases"
20
+ end
data/UPGRADING-3.7.md ADDED
@@ -0,0 +1,86 @@
1
+ # Capistrano 3.7.0 upgrade guide
2
+
3
+ ## The :scm variable is deprecated
4
+
5
+ Up until now, Capistrano's SCM was configured using the `:scm` variable:
6
+
7
+ ```ruby
8
+ # This is now deprecated
9
+ set :scm, :svn
10
+ ```
11
+
12
+ To avoid deprecation warnings:
13
+
14
+ 1. Remove `set :scm, ...` from your Capistrano configuration.
15
+ 2. Add *one* of the following SCM declarations to your `Capfile` after `require "capistrano/deploy"`:
16
+
17
+ ```ruby
18
+ # To use Git
19
+ require "capistrano/scm/git"
20
+ install_plugin Capistrano::SCM::Git
21
+
22
+ # To use Mercurial
23
+ require "capistrano/scm/hg"
24
+ install_plugin Capistrano::SCM::Hg
25
+
26
+ # To use Subversion
27
+ require "capistrano/scm/svn"
28
+ install_plugin Capistrano::SCM::Svn
29
+ ```
30
+
31
+ ## This is the last release where Git is the automatic default
32
+
33
+ If you do not specify an SCM, Capistrano assumes Git. However this behavior is
34
+ now deprecated. Add this to your Capfile to avoid deprecation warnings:
35
+
36
+ ```ruby
37
+ require "capistrano/scm/git"
38
+ install_plugin Capistrano::SCM::Git
39
+ ```
40
+
41
+ ## :git_strategy, :hg_strategy, and :svn_strategy are removed
42
+
43
+ Capistrano 3.7.0 has a rewritten SCM system that relies on "plugins". This
44
+ system is more flexible than the old "strategy" system that only allowed certain
45
+ parts of SCM tasks to be customized.
46
+
47
+ If your deployment relies on a custom SCM strategy, you will need to rewrite
48
+ that strategy to be a full-fledged SCM plugin instead. There is a fairly
49
+ straightforward migration path: write your plugin to be a subclass of the
50
+ built-in SCM that you want to customize. For example:
51
+
52
+ ```ruby
53
+ require "capistrano/scm/git"
54
+
55
+ class MyCustomGit < Capistrano::SCM::Git
56
+ # Override the methods you wish to customize, e.g.:
57
+ def clone_repo
58
+ # ...
59
+ end
60
+ end
61
+ ```
62
+
63
+ Then use your plugin in by loading it in the Capfile:
64
+
65
+ ```ruby
66
+ require_relative "path/to/my_custom_git.rb"
67
+ install_plugin MyCustomGit
68
+ ```
69
+
70
+ ## Existing third-party SCMs are deprecated
71
+
72
+ If you are using a third-party SCM, you can continue using it without
73
+ changes, but you will see deprecation warnings. Contact the maintainer of the
74
+ third-party SCM gem and ask them about modifying the gem to work with the new
75
+ Capistrano 3.7.0 SCM plugin system.
76
+
77
+ ## remote_file is removed
78
+
79
+ The `remote_file` method is no longer in Capistrano 3.7.0. You can read the
80
+ discussion that led to its removal here:
81
+ [issue 762](https://github.com/capistrano/capistrano/issues/762).
82
+
83
+ There is no direct replacement. To migrate to 3.7.0, you will need to rewrite
84
+ any parts of your deployment that use `remote_file` to use a different
85
+ mechanism for uploading files. Consider using the `upload!` method directly in
86
+ a procedural fashion instead.
data/bin/cap CHANGED
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'capistrano/cli'
4
- Capistrano::CLI.execute
2
+ require "capistrano/all"
3
+ Capistrano::Application.new.run
data/bin/capify CHANGED
@@ -1,90 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
- require 'fileutils'
5
-
6
- OptionParser.new do |opts|
7
- opts.banner = "Usage: #{File.basename($0)} [path]"
8
-
9
- opts.on("-h", "--help", "Displays this help info") do
10
- puts opts
11
- exit 0
12
- end
13
-
14
- begin
15
- opts.parse!(ARGV)
16
- rescue OptionParser::ParseError => e
17
- warn e.message
18
- puts opts
19
- exit 1
20
- end
21
- end
22
-
23
- if ARGV.empty?
24
- abort "Please specify the directory to capify, e.g. `#{File.basename($0)} .'"
25
- elsif !File.exists?(ARGV.first)
26
- abort "`#{ARGV.first}' does not exist."
27
- elsif !File.directory?(ARGV.first)
28
- abort "`#{ARGV.first}' is not a directory."
29
- elsif ARGV.length > 1
30
- abort "Too many arguments; please specify only the directory to capify."
31
- end
32
-
33
- def unindent(string)
34
- indentation = string[/\A\s*/]
35
- string.strip.gsub(/^#{indentation}/, "")
36
- end
37
-
38
- files = {
39
- "Capfile" => unindent(<<-FILE),
40
- load 'deploy' if respond_to?(:namespace) # cap2 differentiator
41
-
42
- # Uncomment if you are using Rails' asset pipeline
43
- # load 'deploy/assets'
44
-
45
- Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
46
-
47
- load 'config/deploy' # remove this line to skip loading any of the default tasks
48
- FILE
49
-
50
- "config/deploy.rb" => 'set :application, "set your application name here"
51
- set :repository, "set your repository location here"
52
-
53
- set :scm, :subversion
54
- # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
55
-
56
- role :web, "your web-server here" # Your HTTP server, Apache/etc
57
- role :app, "your app-server here" # This may be the same as your `Web` server
58
- role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
59
- role :db, "your slave db-server here"
60
-
61
- # if you\'re still using the script/reaper helper you will need
62
- # these http://github.com/rails/irs_process_scripts
63
-
64
- # If you are using Passenger mod_rails uncomment this:
65
- # namespace :deploy do
66
- # task :start do ; end
67
- # task :stop do ; end
68
- # task :restart, :roles => :app, :except => { :no_release => true } do
69
- # run "#{try_sudo} touch #{File.join(current_path,\'tmp\',\'restart.txt\')}"
70
- # end
71
- # end'}
72
-
73
- base = ARGV.shift
74
- files.each do |file, content|
75
- file = File.join(base, file)
76
- if File.exists?(file)
77
- warn "[skip] '#{file}' already exists"
78
- elsif File.exists?(file.downcase)
79
- warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'"
80
- else
81
- unless File.exists?(File.dirname(file))
82
- puts "[add] making directory '#{File.dirname(file)}'"
83
- FileUtils.mkdir(File.dirname(file))
84
- end
85
- puts "[add] writing '#{file}'"
86
- File.open(file, "w") { |f| f.write(content) }
87
- end
88
- end
89
-
90
- puts "[done] capified!"
2
+ puts "-" * 80
3
+ puts "Capistrano 3.x is incompatible with Capistrano 2.x. "
4
+ puts
5
+ puts "This command has become `cap install` in Capistrano 3.x"
6
+ puts
7
+ puts "For more information see http://www.capistranorb.com/"
8
+ puts "-" * 80
data/capistrano.gemspec CHANGED
@@ -1,48 +1,34 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require "capistrano/version"
4
6
 
5
- Gem::Specification.new do |s|
6
- s.name = "capistrano"
7
- s.version = Capistrano::Version.to_s
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Jamis Buck", "Lee Hambley"]
10
- s.email = ["jamis@jamisbuck.org", "lee.hambley@gmail.com"]
11
- s.homepage = "http://github.com/capistrano/capistrano"
12
- s.summary = %q{Capistrano - Welcome to easy deployment with Ruby over SSH}
13
- s.description = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.}
14
- s.date = %q{2011-03-22}
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
- s.extra_rdoc_files = [
20
- "README.mdown"
21
- ]
7
+ Gem::Specification.new do |gem|
8
+ gem.name = "capistrano"
9
+ gem.version = Capistrano::VERSION
10
+ gem.authors = ["Tom Clements", "Lee Hambley"]
11
+ gem.email = ["seenmyfate@gmail.com", "lee.hambley@gmail.com"]
12
+ gem.description = "Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH."
13
+ gem.summary = "Capistrano - Welcome to easy deployment with Ruby over SSH"
14
+ gem.homepage = "https://capistranorb.com/"
15
+ gem.metadata = {
16
+ "bug_tracker_uri" => "https://github.com/capistrano/capistrano/issues",
17
+ "changelog_uri" => "https://github.com/capistrano/capistrano/releases",
18
+ "source_code_uri" => "https://github.com/capistrano/capistrano",
19
+ "homepage_uri" => "https://capistranorb.com/",
20
+ "documentation_uri" => "https://capistranorb.com/"
21
+ }
22
+ gem.files = `git ls-files -z`.split("\x0").reject { |f| f =~ /^docs/ }
23
+ gem.executables = %w(cap capify)
24
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
25
+ gem.require_paths = ["lib"]
26
+
27
+ gem.licenses = ["MIT"]
22
28
 
23
- if s.respond_to? :specification_version then
24
- s.specification_version = 3
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<highline>, [">= 0"])
27
- s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.14"])
28
- s.add_runtime_dependency(%q<net-sftp>, [">= 2.0.0"])
29
- s.add_runtime_dependency(%q<net-scp>, [">= 1.0.0"])
30
- s.add_runtime_dependency(%q<net-ssh-gateway>, [">= 1.1.0"])
31
- s.add_development_dependency(%q<mocha>, [">= 0"])
32
- else
33
- s.add_dependency(%q<net-ssh>, [">= 2.0.14"])
34
- s.add_dependency(%q<net-sftp>, [">= 2.0.0"])
35
- s.add_dependency(%q<net-scp>, [">= 1.0.0"])
36
- s.add_dependency(%q<net-ssh-gateway>, [">= 1.1.0"])
37
- s.add_dependency(%q<highline>, [">= 0"])
38
- s.add_dependency(%q<mocha>, [">= 0"])
39
- end
40
- else
41
- s.add_dependency(%q<net-ssh>, [">= 2.0.14"])
42
- s.add_dependency(%q<net-sftp>, [">= 2.0.0"])
43
- s.add_dependency(%q<net-scp>, [">= 1.0.0"])
44
- s.add_dependency(%q<net-ssh-gateway>, [">= 1.1.0"])
45
- s.add_dependency(%q<highline>, [">= 0"])
46
- s.add_dependency(%q<mocha>, [">= 0"])
47
- end
29
+ gem.required_ruby_version = ">= 2.0"
30
+ gem.add_dependency "airbrussh", ">= 1.0.0"
31
+ gem.add_dependency "i18n"
32
+ gem.add_dependency "rake", ">= 10.0.0"
33
+ gem.add_dependency "sshkit", ">= 1.9.0"
48
34
  end
@@ -0,0 +1,8 @@
1
+ name: capistrano
2
+
3
+ services:
4
+ ssh_server:
5
+ build:
6
+ context: .docker
7
+ ports:
8
+ - "2022:22"
@@ -0,0 +1,28 @@
1
+ Feature: The path to the configuration can be changed, removing the need to
2
+ follow Ruby/Rails conventions
3
+
4
+ Background:
5
+ Given a test app with the default configuration
6
+ And servers with the roles app and web
7
+
8
+ Scenario: Deploying with configuration in default location
9
+ When I run "cap test"
10
+ Then the task is successful
11
+
12
+ Scenario: Deploying with configuration in a custom location
13
+ But the configuration is in a custom location
14
+ When I run "cap test"
15
+ Then the task is successful
16
+
17
+ Scenario: Show install task with configuration in default location
18
+ When I run "cap -T"
19
+ Then the task is successful
20
+ And contains "install" in the output
21
+
22
+ Scenario: Hide install task with configuration in a custom location
23
+ And config stage file has line "desc 'Special Task'"
24
+ And config stage file has line "task :special_stage_task"
25
+ But the configuration is in a custom location
26
+ When I run "cap -T"
27
+ Then the task is successful
28
+ And doesn't contain "special_stage_task" in the output
@@ -0,0 +1,92 @@
1
+ Feature: Deploy
2
+
3
+ Background:
4
+ Given a test app with the default configuration
5
+ And servers with the roles app and web
6
+
7
+ Scenario: Creating the repo
8
+ When I run cap "git:check"
9
+ Then the task is successful
10
+ And git wrapper permissions are 0700
11
+
12
+ Scenario: Creating the directory structure
13
+ When I run cap "deploy:check:directories"
14
+ Then the shared path is created
15
+ And the releases path is created
16
+
17
+ Scenario: Creating linked directories
18
+ When I run cap "deploy:check:linked_dirs"
19
+ Then directories in :linked_dirs are created in shared
20
+
21
+ Scenario: Creating linked directories for linked files
22
+ When I run cap "deploy:check:make_linked_dirs"
23
+ Then directories referenced in :linked_files are created in shared
24
+
25
+ Scenario: Checking linked files - missing file
26
+ Given a linked file "missing_file.txt"
27
+ But file "missing_file.txt" does not exist in shared path
28
+ When I run cap "deploy:check:linked_files"
29
+ Then the task fails
30
+
31
+ Scenario: Checking linked files - file exists
32
+ Given a linked file "existing_file.txt"
33
+ And file "existing_file.txt" exists in shared path
34
+ When I run cap "deploy:check:linked_files"
35
+ Then the task is successful
36
+
37
+ Scenario: Creating a release
38
+ Given I run cap "deploy:check:directories"
39
+ When I run cap "git:create_release" as part of a release
40
+ Then the repo is cloned
41
+ And the release is created
42
+
43
+ Scenario: REVISION and REVISION_TIME files are present
44
+ When I make 1 deployment
45
+ Then the REVISION file is created in the release
46
+ Then the REVISION_TIME file is created in the release
47
+
48
+ Scenario: Symlink linked files
49
+ When I run cap "deploy:symlink:linked_files deploy:symlink:release" as part of a release
50
+ Then file symlinks are created in the new release
51
+
52
+ Scenario: Symlink linked dirs
53
+ When I run cap "deploy:symlink:linked_dirs" as part of a release
54
+ Then directory symlinks are created in the new release
55
+
56
+ Scenario: Publishing
57
+ When I run cap "deploy:symlink:release"
58
+ Then the current directory will be a symlink to the release
59
+
60
+ Scenario: Cleanup
61
+ Given config stage file has line "set :keep_releases, 3"
62
+ And 5 valid existing releases
63
+ And an invalid release named "new"
64
+ When I run cap "deploy:cleanup"
65
+ Then 3 valid releases are kept
66
+ And the invalid "new" release is ignored
67
+
68
+ Scenario: Cleanup after many failed releases doesn't remove last good release
69
+ Given config stage file has line "set :keep_releases, 2"
70
+ And I make 2 deployments
71
+ And an invalid release named "77777777777777"
72
+ And an invalid release named "88888888888888"
73
+ And an invalid release named "99999999999999"
74
+ When I run cap "deploy:cleanup"
75
+ Then 3 valid releases are kept
76
+ And the current directory will be a symlink to the release
77
+
78
+ Scenario: Cleanup when there are more releases than arguments can handle
79
+ Given config stage file has line "set :keep_releases, 3"
80
+ And 5000 valid existing releases
81
+ When I run cap "deploy:cleanup"
82
+ Then 3 valid releases are kept
83
+
84
+ Scenario: Rolling Back
85
+ Given I make 2 deployments
86
+ When I run cap "deploy:rollback"
87
+ Then the current symlink points to the previous release
88
+
89
+ Scenario: Rolling Back to a specific release
90
+ Given I make 3 deployments
91
+ When I rollback to a specific release
92
+ Then the current symlink points to that specific release