Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Built in capistrano variables

Does anybody know a listing of all build-in Capistrano variables, like current_path and etc.?

like image 396
ggboy Avatar asked Dec 07 '10 19:12

ggboy


2 Answers

You can find all of them at:

https://github.com/capistrano/capistrano/blob/legacy-v2/lib/capistrano/recipes/deploy.rb

Update: v3 no longer has the same configuration options as v2. I linked the v2 config options above, but the v3 has the following:

Capistrano configuration variables

Here are the legacy ones, preserved in this post:

# =========================================================================
# These variables MUST be set in the client capfiles. If they are not set,
# the deploy will fail with an error.
# =========================================================================

_cset(:application) { abort "Please specify the name of your application, set :application, 'foo'" }
_cset(:repository)  { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" }

# =========================================================================
# These variables may be set in the client capfile if their default values
# are not sufficient.
# =========================================================================

_cset(:scm) { scm_default }
_cset :deploy_via, :checkout

_cset(:deploy_to) { "/u/apps/#{application}" }
_cset(:revision)  { source.head }

_cset :rails_env, "production"
_cset :rake, "rake"

# =========================================================================
# These variables should NOT be changed unless you are very confident in
# what you are doing. Make sure you understand all the implications of your
# changes if you do decide to muck with these!
# =========================================================================

_cset(:source)            { Capistrano::Deploy::SCM.new(scm, self) }
_cset(:real_revision)     { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } }

_cset(:strategy)          { Capistrano::Deploy::Strategy.new(deploy_via, self) }

# If overriding release name, please also select an appropriate setting for :releases below.
_cset(:release_name)      { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") }

_cset :version_dir,       "releases"
_cset :shared_dir,        "shared"
_cset :shared_children,   %w(public/system log tmp/pids)
_cset :current_dir,       "current"

_cset(:releases_path)     { File.join(deploy_to, version_dir) }
_cset(:shared_path)       { File.join(deploy_to, shared_dir) }
_cset(:current_path)      { File.join(deploy_to, current_dir) }
_cset(:release_path)      { File.join(releases_path, release_name) }

_cset(:releases)          { capture("#{try_sudo} ls -x #{releases_path}", :except => { :no_release => true }).split.sort }
_cset(:current_release)   { releases.length > 0 ? File.join(releases_path, releases.last) : nil }
_cset(:previous_release)  { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil }

_cset(:current_revision)  { capture("#{try_sudo} cat #{current_path}/REVISION",     :except => { :no_release => true }).chomp }
_cset(:latest_revision)   { capture("#{try_sudo} cat #{current_release}/REVISION",  :except => { :no_release => true }).chomp }
_cset(:previous_revision) { capture("#{try_sudo} cat #{previous_release}/REVISION", :except => { :no_release => true }).chomp if previous_release }

_cset(:run_method)        { fetch(:use_sudo, true) ? :sudo : :run }

# some tasks, like symlink, need to always point at the latest release, but
# they can also (occassionally) be called standalone. In the standalone case,
# the timestamped release_path will be inaccurate, since the directory won't
# actually exist. This variable lets tasks like symlink work either in the
# standalone case, or during deployment.
_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }

_cset :maintenance_basename, "maintenance"
_cset(:maintenance_template_path) { File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml") }
like image 165
Chuck Callebs Avatar answered Nov 01 '22 16:11

Chuck Callebs


It appears that Cap 3 has spread the defaults out over multiple files. Here's my reconstruction based on searching for Cap 2 defaults from the posted link in the Cap 3 master branch:

  • https://github.com/capistrano/capistrano/blob/ee96c2e77a57c8facf52854eb14d6b57b2b0e5e7/lib/capistrano/defaults.rb
  • https://github.com/capistrano/capistrano/blob/aeab6b6a1e5c5e654f35321dcd7438a0659864d0/lib/capistrano/dsl/paths.rb

From the second link you can see that a few variables in V2 are now converted to reader methods (which means you don't need to fetch them):

  • deploy_to
  • deploy_path
  • current_path
  • releases_path
  • release_path
  • stage_config_path
  • deploy_config_path
  • repo_url
  • repo_path
  • shared_path
  • revision_log
  • now
  • asset_timestamp
like image 5
sameers Avatar answered Nov 01 '22 17:11

sameers