Class: Capistrano::Deploy::Strategy::Copy

### Home Classes Methods

### In Files

- lib/capistrano/recipes/deploy/strategy/copy.rb

### Parent

Capistrano::Deploy::Strategy::Base

### Methods

- #build
- #check!
- #copy_cache
- #deploy!

### Files

- help.txt

### Class/Module Index

Quicksearch

- Capistrano
- Capistrano::CLI
- Capistrano::CLI::Execute
- Capistrano::CLI::Execute::ClassMethods
- Capistrano::CLI::Help
- Capistrano::CLI::Options
- Capistrano::CLI::Options::ClassMethods
- Capistrano::CLI::UI
- Capistrano::CLI::UI::ClassMethods
- Capistrano::Callback
- Capistrano::Command
- Capistrano::Command::Tree
- Capistrano::Command::Tree::Branch
- Capistrano::Command::Tree::ConditionBranch
- Capistrano::Command::Tree::ConditionBranch::Evaluator
- Capistrano::Command::Tree::ElseBranch
- Capistrano::Configuration
- Capistrano::Configuration::Actions
- Capistrano::Configuration::Actions::FileTransfer
- Capistrano::Configuration::Actions::Inspect
- Capistrano::Configuration::Actions::Invocation
- Capistrano::Configuration::Actions::Invocation::ClassMethods
- Capistrano::Configuration::AliasTask
- Capistrano::Configuration::Callbacks
- Capistrano::Configuration::Connections
- Capistrano::Configuration::Execution
- Capistrano::Configuration::Loading
- Capistrano::Configuration::Loading::ClassMethods
- Capistrano::Configuration::LogFormatters
- Capistrano::Configuration::Namespaces
- Capistrano::Configuration::Namespaces::Namespace
- Capistrano::Configuration::Roles
- Capistrano::Configuration::Servers
- Capistrano::Configuration::Variables
- Capistrano::Deploy
- Capistrano::Deploy::Dependencies
- Capistrano::Deploy::LocalDependency
- Capistrano::Deploy::RemoteDependency
- Capistrano::Deploy::SCM
- Capistrano::Deploy::SCM::Accurev
- Capistrano::Deploy::SCM::Accurev::InternalRevision
- Capistrano::Deploy::SCM::Base
- Capistrano::Deploy::SCM::Base::LocalProxy
- Capistrano::Deploy::SCM::Bzr
- Capistrano::Deploy::SCM::Cvs
- Capistrano::Deploy::SCM::Darcs
- Capistrano::Deploy::SCM::Git
- Capistrano::Deploy::SCM::Mercurial
- Capistrano::Deploy::SCM::None
- Capistrano::Deploy::SCM::Perforce
- Capistrano::Deploy::SCM::Subversion
- Capistrano::Deploy::Strategy
- Capistrano::Deploy::Strategy::Base
- Capistrano::Deploy::Strategy::Checkout
- Capistrano::Deploy::Strategy::Copy
- Capistrano::Deploy::Strategy::Export
- Capistrano::Deploy::Strategy::Remote
- Capistrano::Deploy::Strategy::RemoteCache
- Capistrano::Deploy::Strategy::UnsharedRemoteCache
- Capistrano::ProcCallback
- Capistrano::Processable
- Capistrano::Processable::SessionAssociation
- Capistrano::RemoteError
- Capistrano::Role
- Capistrano::Role::DynamicServerList
- Capistrano::SSH
- Capistrano::ServerDefinition
- Capistrano::Shell
- Capistrano::TaskCallback
- Capistrano::TaskDefinition
- Capistrano::Transfer
- Capistrano::Transfer::SFTPTransferWrapper
- Capistrano::Version
- Kernel
- Object
- String

No matching classes.

# Capistrano::Deploy::Strategy::Copy

This class implements the strategy for deployments which work by preparing the source code locally, compressing it, copying the file to each target host, and uncompressing it to the deployment directory.

By default, the SCM checkout command is used to obtain the local copy of the source code. If you would rather use the export operation, you can set the :copy_strategy variable to :export.

    set :copy_strategy, :export

For even faster deployments, you can set the :copy_cache variable to true. This will cause deployments to do a new checkout of your repository to a new directory, and then copy that checkout. Subsequent deploys will just resync that copy, rather than doing an entirely new checkout. Additionally, you can specify file patterns to exclude from the copy when using :copy_cache; just set the :copy_exclude variable to a file glob (or an array of globs).

    set :copy_cache, true
    set :copy_exclude, ".git/*"

Note that :copy_strategy is ignored when :copy_cache is set. Also, if you want the copy cache put somewhere specific, you can set the variable to the path you want, instead of merely 'true':

    set :copy_cache, "/tmp/caches/myapp"

This deployment strategy also supports a special variable, :copy_compression, which must be one of :gzip, :bz2, or :zip, and which specifies how the source should be compressed for transmission to each host.

By default, files will be transferred across to the remote machines via 'sftp'. If you prefer to use 'scp' you can set the :copy_via variable to :scp.

    set :copy_via, :scp

There is a possibility to pass a build command that will get executed if your code needs to be compiled or something needs to be done before the code is ready to run.

    set :build_script, "make all"

Note that if you use :copy_cache, the :build_script is used on the cache and thus you get faster compilation if your script does not recompile everything.

### Constants

Compression

  A struct for representing the specifics of a compression type. Commands are arrays, where the first element is the utility to be used to perform the compression or decompression.

### Public Instance Methods

build(directory) click to toggle source

    # File lib/capistrano/recipes/deploy/strategy/copy.rb, line 71
    def build directory
      execute "running build script on #{directory}" do
        Dir.chdir(directory) { system(build_script) }
      end if build_script
    end

check!() click to toggle source

    # File lib/capistrano/recipes/deploy/strategy/copy.rb, line 77
    def check!
      super.check do |d|
        d.local.command(source.local.command) if source.local.command
        d.local.command(compress(nil, nil).first)
        d.remote.command(decompress(nil).first)
      end
    end

copy_cache() click to toggle source

Returns the location of the local copy cache, if the strategy should use a local cache + copy instead of a new checkout/export every time. Returns `nil` unless :copy_cache has been set. If :copy_cache is `true`, a default cache location will be returned.

    # File lib/capistrano/recipes/deploy/strategy/copy.rb, line 89
    def copy_cache
      @copy_cache ||= configuration[:copy_cache] == true ?
        File.expand_path(configuration[:application], Dir.tmpdir) :
        File.expand_path(configuration[:copy_cache], Dir.pwd) rescue nil
    end

deploy!() click to toggle source

Obtains a copy of the source code locally (via the command method), compresses it to a single file, copies that file to all target servers, and uncompresses it on each of them into the deployment directory.

    # File lib/capistrano/recipes/deploy/strategy/copy.rb, line 61
    def deploy!
      copy_cache ? run_copy_cache_strategy : run_copy_strategy

      create_revision_file
      compress_repository
      distribute!
    ensure
      rollback_changes
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.